DEV Community

Cover image for Setup MonoRepo in Nest.js
Bhat Aasim
Bhat Aasim

Posted on

8 1 1

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.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay