Setup MonoRepo in Nest.js

bhataasim

Bhat Aasim

Posted on July 4, 2024

Setup MonoRepo in Nest.js

Welcome, to my First Post!

About Me:
Hi, My name is Aasim Ashraf, I am a Full-Stack dev.

What is Monorepo?
A monorepo is a version-controlled code repository that contains multiple logical projects within a single repository.

Let's Create our Own MonoRepo using Nest.js
Before we dive into creating our monorepo, make sure you have the following:

  • Node.js installed on your system.
  • npm

Let's Get Started.

  1. Install the Nest.js CLI:
    npm i -g @nestjs/cli

  2. Create a New Project:: nest new [project name]
    like we will create a demo app. nest new demo

Creating demo Project

  1. Select the Package manager npm, pnpm, yarn any of these and hit enter.

  2. Wait for the dependencies to install and open the demo app in your preferred code editor, such as VSCode.

project opened in Vscode

  1. Convert the Nest.js App into a Monorepo, Open the Terminal and type nest g app my-app1

Converting basic app into monorepo

This command will delete the src directory and create a new apps directory. Inside this directory, you'll find the demo and my-app1.

Monorepo folder structure

  1. Your Monorepo is Ready. You have successfully converted the basic nest.js app into a mono-repo.

You can add libraries that could contain the common logic etc.

use Command nest g lib [library name]

eg. nest g lib auth
this auth lib will contain the code related to the authentication only.

Added Libarary into the Monorepo

I hope you have enjoyed this.
Thanks for bearing with me.

💖 💪 🙅 🚩
bhataasim
Bhat Aasim

Posted on July 4, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Setup MonoRepo in Nest.js
nestjs Setup MonoRepo in Nest.js

July 4, 2024