NestJS - Getting Started

Nikos Oikonomou
2 min readJan 27, 2024

In this section, we’ll create a new NestJS project and execute some basic setup steps to start the development.

This section is part of a larger guide.

Install NodeJS using Node Version Manager.

# Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
# install latest nodejs version
nvm install node # alternatively nvm install <your-desired-node-version>

Project initialization

# First of all we need to install NestJS CLI
npm i -g @nestjs/cli
# Generate the NestJS repository
nest new nestjs-app # you can select your desired application name
cd nestjs-app # navigate to your app’s root directory
# Save your current node version for future usage
node -v > .nvmrc # saves current nodejs version
nvm use # loads and uses saved nodejs version

Now you have a fully operational NestJS project so you can start the development. You can verify that everything went well by running your default application:

npm run start      # development
npm run start:dev # watch mode
npm run start:prod # production mode

Or test your code

npm run test     # unit tests
npm run test:e2e # e2e tests
npm run test:cov # test coverage

Or fix its quality:

npm run format && npm run lint

Now that everything is set up we can start the development. But before that let’s showcase some of the NestJS basics.

--

--