0
0
NestJSframework~5 mins

NestJS CLI installation

Choose your learning style9 modes available
Introduction

The NestJS CLI helps you create and manage NestJS projects easily. It saves time by generating code and running commands for you.

When starting a new NestJS project quickly without setting up files manually.
When you want to generate modules, controllers, or services automatically.
When you need to run your NestJS app or build it using simple commands.
When you want to keep your project organized with standard NestJS structure.
When you want to update or add features using CLI commands instead of writing boilerplate code.
Syntax
NestJS
npm install -g @nestjs/cli
Use -g to install the CLI globally so you can use it anywhere on your computer.
Make sure you have Node.js and npm installed before running this command.
Examples
Installs the NestJS CLI globally on your system.
NestJS
npm install -g @nestjs/cli
Checks the installed version of the NestJS CLI to confirm installation.
NestJS
nest --version
Creates a new NestJS project folder named project-name using the CLI.
NestJS
nest new project-name
Sample Program

This installs the NestJS CLI globally and then shows the installed version to confirm it works.

NestJS
npm install -g @nestjs/cli
nest --version
OutputSuccess
Important Notes

If you get permission errors on Linux or Mac, try adding sudo before the install command.

After installation, you can run nest commands anywhere in your terminal.

Keep your CLI updated by running npm update -g @nestjs/cli regularly.

Summary

The NestJS CLI makes starting and managing projects simple and fast.

Install it globally with npm install -g @nestjs/cli.

Use nest commands to create projects and generate code.