Node.js
npm
JavaScript
web development
project setup
programming
software development

How to set up Node.js, npm, and a project folder

Listen to article
Deepak Tewatia
September 6, 2025
3 min read

Introduction

Setting up Node.js and npm is a straightforward process. With just a few steps, you can have everything you need to start building your web applications. Let's dive into how to do this, step by step.

What is Node.js?

Node.js is a runtime that allows you to run JavaScript on the server side. It's built on Chrome's V8 JavaScript engine, making it fast and efficient. You can use Node.js to create all kinds of applications, from simple scripts to complex web servers.

What is npm?

npm stands for Node Package Manager. It comes with Node.js and helps you manage packages or libraries that you can use in your projects. With npm, you can easily install, update, and manage your dependencies.

Step 1: Download and Install Node.js

To begin, you need to download Node.js. Here’s how:

  1. Go to the official Node.js website.
  2. You will see two versions: LTS (Long Term Support) and Current. If you are just starting, download the LTS version.
  3. Run the installer and follow the steps. During the installation, make sure to check the box that says "Add to PATH".

After the installation, you can check if Node.js and npm are installed correctly by opening your command line and typing the following commands:

node -v
npm -v

If both commands show version numbers, you’re good to go!

Step 2: Create Your Project Folder

Now, let’s create a new folder for your project. Here’s how to do it:

  1. Open your command line.
  2. Decide where you want to create your project folder. Use the cd command to navigate to that location. For example:
cd path/to/your/directory
  • Now, create a new folder using the mkdir command. Replace my-project with your desired folder name:
mkdir my-project
  • Next, navigate into your new folder:
cd my-project

Step 3: Initialize Your Project with npm

Now that you have your project folder, the next step is to set it up with npm. You do this by initializing a new project. Just type:

npm init

This command will prompt you to answer some questions about your project, like its name, version, description, entry point, test command, and so on. You can hit Enter to accept the default settings for any question you don’t want to answer right away.

Step 4: Install Packages

Once your project is set up, you can start adding packages. For example, if you want to use Express, a popular web framework for Node.js, you can install it using npm. Just type:

npm install express

This command installs Express and saves it in your package.json file, which keeps track of all your project's dependencies.

Step 5: Create Your First JavaScript File

Now that you have everything set up, it’s time to create your first JavaScript file. You can create a new file named app.js in your project folder. Use any text editor or IDE you like.

In app.js, you can write a simple "Hello World" server using Express:

const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.listen(PORT, () => {
  console.log(`Server is running on http://localhost:${PORT}`);
});

Save the file. To run your server, go back to your command line and type:

node app.js

Now, open your web browser and go to http://localhost:3000. You should see "Hello World!" on your screen. That’s your first Node.js application running!

Conclusion

Setting up Node.js and npm is easy. You’ve successfully installed everything, created a project folder, initialized npm, and even run your first server. From here, you can explore more about Node.js and build amazing applications. Happy coding!

Comments

Y
You
Commenting
0/2000
Loading comments…