Getting Started with Nest.js: A Step-by-Step Guide to Setting Up Nest.js Locally

Kasun Abaywardana
2 min readMay 23, 2023

--

Welcome to the world of Nest.js! In this introductory guide, we’ll walk you through the seamless process of setting up Nest.js locally. Nest.js, a powerful Node.js framework, provides a solid foundation for building scalable and maintainable applications. Whether you’re a seasoned developer or just getting started with backend development, this step-by-step tutorial will equip you with the knowledge to kickstart your Nest.js projects efficiently. Let’s dive in and embark on an exciting journey of Nest.js development!

Pre requests

To begin the process, it is essential to have Node.js installed on your local computer. If you have already installed Node.js, you can skip this section. However, if you are starting fresh and need to install Node.js, please follow the steps below:

Step 1: Visit the official Node.js website (https://nodejs.org) and download the latest stable version(LTS) of Node.js for your operating system.

Step 2: Run the downloaded installation file and follow the on-screen instructions to install Node.js.

Step 3: After the installation completes, open a new terminal or command prompt window to verify that Node.js is installed correctly. To do this, type the following command and press Enter: node -v

It gives an output like a bellow

Install Nest JS CLI

Next, we need to install the Nest.js CLI, which will allow us to generate new Nest.js projects with ease. To install the Nest.js CLI, follow the command below. This command will install the CLI globally on your computer Please enter: npm install -g @nestjs/cli

Then we can identify the available commands in Nest JS CLI. Bellow screenshot displays the available commands in Nest JS CLI.

Generate Nest JS new project

Now that we have all the necessary infrastructure in place, we are ready to start a new Nest.js project. To generate a new project, we will utilize the previously installed Nest.js CLI. Follow the steps below:

  • Open the terminal and navigate to a specific folder you need to place the project.
  • Then use the nest new my-project command to generate a new project
  • After the new project generation that folder structure looks like below.

In the next section, I hope to discuss How we can connect PgSQL to Nest JS project.

Let's do it tougher …

--

--

Kasun Abaywardana

Kasun Abaywardana: 7+ yrs software dev exp. JS specialist in React, Node, Angular, MongoDB. Passionate about creating innovative solutions.