How to Install Nodejs

How to Install Node.js: A Complete Step-by-Step Guide for Developers Node.js has become one of the most essential tools in modern web development. Built on Chrome’s V8 JavaScript engine, Node.js allows developers to run JavaScript on the server side, enabling seamless full-stack development using a single language. Whether you're building REST APIs, real-time applications, microservices, or comman

Nov 10, 2025 - 12:35
Nov 10, 2025 - 12:35
 1

How to Install Node.js: A Complete Step-by-Step Guide for Developers

Node.js has become one of the most essential tools in modern web development. Built on Chromes V8 JavaScript engine, Node.js allows developers to run JavaScript on the server side, enabling seamless full-stack development using a single language. Whether you're building REST APIs, real-time applications, microservices, or command-line tools, Node.js provides the performance, scalability, and ecosystem needed to succeed.

Installing Node.js correctly is the first critical step in your development journey. A poorly configured installation can lead to dependency conflicts, version mismatches, permission errors, or compatibility issues with modern frameworks like Express, NestJS, or Next.js. This guide walks you through every aspect of installing Node.js on Windows, macOS, and Linux systems from downloading the right version to verifying your setup and optimizing your environment for long-term productivity.

By the end of this tutorial, youll not only know how to install Node.js youll understand how to manage multiple versions, avoid common pitfalls, and leverage the full power of the Node.js ecosystem from day one.

Step-by-Step Guide

Understanding Node.js Versions: LTS vs Current

Before installing Node.js, its vital to understand the two main release channels: LTS (Long-Term Support) and Current.

LTS versions are recommended for most users, especially in production environments. They receive at least 12 months of active support and an additional 18 months of maintenance, ensuring stability, security patches, and compatibility with enterprise tools. LTS releases are numbered with even digits (e.g., 20.x, 22.x).

Current versions include the latest features, performance improvements, and APIs. These are ideal for developers experimenting with new functionality or contributing to open-source projects. However, they are not recommended for production use due to potential instability and shorter support cycles.

Always choose the LTS version unless you have a specific need for the latest features. As of 2024, Node.js 20.x is the current LTS release, with Node.js 22.x in the Current channel.

Installing Node.js on Windows

Windows users have two primary methods to install Node.js: using the official installer or a version manager like nvm-windows.

Method 1: Official Installer (Recommended for Beginners)

  1. Visit the official Node.js website at https://nodejs.org.
  2. On the homepage, youll see two download buttons: one for the LTS version and one for the Current version. Click the LTS button.
  3. Once the installer (a .msi file) finishes downloading, double-click it to launch the setup wizard.
  4. Follow the prompts: accept the license agreement, choose the installation location (default is fine), and click Next through each screen.
  5. Ensure that the option to install npm (Node Package Manager) is selected its enabled by default.
  6. Click Install and wait for the process to complete.
  7. After installation, click Finish.

To verify the installation, open a new Command Prompt or PowerShell window and run:

node --version

npm --version

You should see output similar to:

v20.12.2

10.5.2

If you see version numbers, Node.js and npm are successfully installed.

Method 2: Using nvm-windows (Recommended for Advanced Users)

If you plan to work on multiple projects requiring different Node.js versions, use nvm-windows (Node Version Manager for Windows).

  1. Go to the nvm-windows GitHub releases page: https://github.com/coreybutler/nvm-windows/releases.
  2. Download the nvm-setup.exe file (latest version).
  3. Run the installer as Administrator. Accept defaults during installation.
  4. After installation, open a new Command Prompt or PowerShell window and type:
nvm version

If you see a version number, nvm-windows is installed correctly.

To install the latest LTS version of Node.js:

nvm install latest

To install a specific LTS version:

nvm install 20

To switch to a specific version:

nvm use 20

To list all installed versions:

nvm list

nvm-windows gives you full control over Node.js versions and avoids conflicts between projects. Its the preferred method for professional developers.

Installing Node.js on macOS

macOS users can install Node.js via the official installer, Homebrew, or nvm. Homebrew and nvm are preferred for their flexibility and version management.

Method 1: Using Homebrew (Recommended)

Homebrew is the most popular package manager for macOS. If you dont have it installed:

  1. Open Terminal (Applications ? Utilities ? Terminal).
  2. Run the following command to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Follow the on-screen instructions. After installation, restart your terminal or run:

source ~/.zshrc

Now install Node.js:

brew install node

Verify the installation:

node --version

npm --version

Homebrew automatically installs the latest LTS version of Node.js and npm.

Method 2: Using nvm (Node Version Manager)

nvm is the most flexible option for managing multiple Node.js versions on macOS.

  1. Open Terminal.
  2. Install nvm by running:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

Or use wget:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

After installation, close and reopen Terminal, or reload your shell configuration:

source ~/.zshrc

Install the latest LTS version:

nvm install --lts

Set it as default:

nvm use --lts

nvm alias default lts/*

Check your installed versions:

nvm list

nvm allows you to switch between Node.js versions per project, making it indispensable for developers working on legacy and modern applications simultaneously.

Method 3: Official Installer (Alternative)

If you prefer a GUI installer:

  1. Go to https://nodejs.org.
  2. Download the macOS .pkg installer for LTS.
  3. Double-click the file and follow the installation wizard.
  4. Restart your terminal and verify with node --version.

While simple, this method does not allow version switching. Use it only if youre certain youll only need one Node.js version.

Installing Node.js on Linux (Ubuntu, Debian, CentOS, Fedora)

Linux distributions vary in package management, so well cover the most common methods for Ubuntu/Debian and CentOS/Fedora.

Ubuntu / Debian

Method 1: Using NodeSource Repository (Recommended)
  1. Open Terminal.
  2. Update your package list:
sudo apt update

  1. Install curl (if not already installed):
sudo apt install curl

  1. Add the NodeSource repository for Node.js 20.x (LTS):
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

  1. Install Node.js:
sudo apt install -y nodejs

  1. Verify installation:
node --version

npm --version

Method 2: Using nvm (Best for Multi-Version Support)
  1. Install curl and build tools:
sudo apt update && sudo apt install curl build-essential -y

  1. Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

  1. Reload your shell:
source ~/.bashrc

  1. Install and use LTS:
nvm install --lts

nvm use --lts

nvm alias default lts/*

CentOS / Fedora

Method 1: Using NodeSource Repository
  1. Open Terminal.
  2. Install curl:
sudo yum install curl -y

Or for Fedora:

sudo dnf install curl -y

  1. Add the NodeSource repository:

For CentOS/RHEL:

curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -

For Fedora:

curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -

  1. Install Node.js:
sudo yum install -y nodejs

Or for Fedora:

sudo dnf install -y nodejs

  1. Verify:
node --version

npm --version

Method 2: Using nvm

The nvm installation process is identical to Ubuntu. Install curl, run the nvm install script, then use nvm install --lts.

Best Practices

Always Use a Version Manager

Whether youre on macOS, Linux, or Windows, using a version manager like nvm (or nvm-windows) is a best practice. It prevents conflicts between projects, allows you to test against different Node.js versions, and makes it easy to revert if a new version breaks your code.

Without a version manager, upgrading Node.js system-wide can break existing applications. With nvm, you can have Node.js 18 for an old Express app and Node.js 20 for a new NestJS API all on the same machine.

Use .nvmrc for Project-Specific Versions

Create a file named .nvmrc in the root of each project and specify the required Node.js version:

20.12.2

Then, in your project directory, run:

nvm use

nvm will automatically detect and switch to the version specified in .nvmrc. This is especially useful for team collaboration anyone cloning your repository will know exactly which Node.js version to use.

Keep npm and Node.js Updated

While LTS versions are stable, npm (Node Package Manager) receives frequent updates for security and performance. Regularly update npm:

npm install -g npm@latest

However, avoid updating Node.js itself unless necessary. Stick to LTS versions for production and use nvm to test newer versions in isolated environments.

Use a .npmrc File for Configuration

Customize npm behavior per project using a .npmrc file. For example:

registry=https://registry.npmjs.org/

cache=/home/user/.npm-cache

init-author-name=Your Name

This ensures consistent behavior across development and CI environments.

Install Global Packages with Care

Global packages (installed with -g) are accessible system-wide. Common examples include:

  • npm install -g nodemon auto-restarts server on file changes
  • npm install -g typescript TypeScript compiler
  • npm install -g express-generator scaffolds Express apps

However, installing too many global packages can lead to conflicts. Prefer local installations where possible. Use npx to run packages without installing them globally:

npx nodemon server.js

npx create-react-app my-app

npx downloads and executes packages temporarily, eliminating the need for global installs in many cases.

Set Up Environment Variables

For advanced workflows, set environment variables to control Node.js behavior:

  • NODE_ENV=production enables optimizations in frameworks like Express
  • NODE_OPTIONS=--max-old-space-size=4096 increases memory limit for large apps

On Linux/macOS, set them in your shell profile (e.g., ~/.bashrc or ~/.zshrc):

export NODE_ENV=production

export NODE_OPTIONS=--max-old-space-size=4096

On Windows, use PowerShell:

[Environment]::SetEnvironmentVariable("NODE_ENV", "production", "User")

Use a linter and formatter

Install ESLint and Prettier to maintain code quality:

npm install --save-dev eslint prettier eslint-config-prettier eslint-plugin-prettier

Configure them with .eslintrc.json and .prettierrc files. This ensures consistent code style across your team.

Tools and Resources

Essential Node.js Tools

Once Node.js is installed, these tools will accelerate your development workflow:

  • npm Node Package Manager. Default package manager for installing libraries.
  • yarn Alternative package manager by Facebook. Faster and more deterministic than npm.
  • npx Executes packages without installing them globally. Built into npm 5.2+.
  • nodemon Automatically restarts your Node.js server during development when files change.
  • pm2 Production process manager for Node.js applications. Handles clustering, logging, and auto-restart.
  • Visual Studio Code The most popular code editor with excellent Node.js support via extensions like ESLint, Prettier, and Debugger for Node.js.
  • Postman Test your APIs during development.
  • Insomnia Open-source alternative to Postman.

Package Managers Comparison

Feature npm yarn pnpm
Speed Medium Fast Very Fast
Security Good Excellent Excellent
Disk Usage High Medium Low (hard links)
Lockfile package-lock.json yarn.lock pnpm-lock.yaml
Global Installs Yes Yes Yes

While npm is the default, many teams prefer pnpm for its efficiency and security. To install pnpm:

npm install -g pnpm

Then use it like npm:

pnpm install

pnpm add express

pnpm run dev

Documentation and Learning Resources

Monitoring and Debugging Tools

  • Node.js Inspector Built-in debugger accessible via node --inspect server.js.
  • Chrome DevTools Connect to the inspector to debug Node.js applications visually.
  • clinic.js Performance profiling tool for identifying bottlenecks.
  • pm2 monit Real-time monitoring of CPU, memory, and process status.
  • Winston Popular logging library for structured logs.

Real Examples

Example 1: Setting Up a Simple Express Server

After installing Node.js, create your first server:

  1. Create a project folder:
mkdir my-first-node-app

cd my-first-node-app

  1. Initialize npm:
npm init -y

  1. Install Express:
npm install express

  1. Create server.js:
const express = require('express');

const app = express();

const PORT = 3000;

app.get('/', (req, res) => {

res.send('Hello, Node.js!');

});

app.listen(PORT, () => {

console.log(Server running on http://localhost:${PORT});

});

  1. Run the server:
node server.js

Visit http://localhost:3000 in your browser. You should see Hello, Node.js!

Example 2: Using nvm to Manage Multiple Projects

Imagine youre maintaining two apps:

  • Project A: Built on Node.js 16 (legacy)
  • Project B: Built on Node.js 20 (modern)

Install both versions:

nvm install 16

nvm install 20

In Project As folder:

echo "16" > .nvmrc

nvm use

In Project Bs folder:

echo "20" > .nvmrc

nvm use

Now, when you switch between folders, nvm automatically selects the correct Node.js version. No more Module not found errors due to version mismatches.

Example 3: CI/CD Pipeline with Node.js

In a GitHub Actions workflow, you can specify the Node.js version:

name: CI

on: [push, pull_request]

jobs:

test:

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v4

- uses: actions/setup-node@v4

with:

node-version: '20'

- run: npm ci

- run: npm test

This ensures your app is tested on the exact Node.js version used in production eliminating works on my machine issues.

Example 4: Using pnpm for Large Monorepos

At a company with 50+ microservices, using npm led to 5GB of node_modules across repositories. Switching to pnpm reduced disk usage to 800MB:

Install pnpm globally

npm install -g pnpm

In each package

pnpm install

pnpm run build

pnpms hard-linking strategy saves space and improves install speed by 5070% in large projects.

FAQs

Can I install Node.js without admin rights?

On Windows, you can use nvm-windows without admin rights if installed in your user directory. On macOS and Linux, nvm installs in your home folder and requires no sudo privileges. The official installer typically requires admin rights.

What if I get a command not found error after installing Node.js?

This usually means the installation path isnt in your systems PATH environment variable. Restart your terminal. If the issue persists, reinstall using nvm or verify your shell profile (e.g., .bashrc, .zshrc) includes the correct export paths.

Do I need to install Python or Visual Studio for Node.js?

On Windows, some native npm packages (like those with C++ bindings) require build tools. Install the Windows Build Tools via:

npm install -g windows-build-tools

On Linux, ensure you have build-essential (Ubuntu) or gcc-c++ (CentOS) installed.

How do I uninstall Node.js completely?

Windows: Use Programs & Features to uninstall Node.js. Delete C:\Program Files\nodejs and %APPDATA%\npm.

macOS (Homebrew): brew uninstall node

macOS/Linux (nvm): nvm uninstall 20 (replace with version number). Delete the .nvm folder if you want to remove nvm entirely.

Is Node.js safe to install?

Yes, Node.js is safe when downloaded from nodejs.org. Avoid third-party installers or unofficial sources. Always verify the checksum of downloaded files if youre in a high-security environment.

Whats the difference between Node.js and JavaScript?

JavaScript is a programming language. Node.js is a runtime environment that executes JavaScript outside the browser primarily on servers. Node.js adds APIs for file systems, networking, and more that arent available in browsers.

Should I use Node.js for backend development?

Yes. Node.js is widely used for backend development due to its non-blocking I/O, scalability, and vast ecosystem. Companies like Netflix, Uber, and LinkedIn rely on Node.js for high-performance backend services.

Can I run Node.js on a Raspberry Pi?

Yes. Download the ARM build from nodejs.org or use nvm on Raspberry Pi OS. Its commonly used for IoT projects and home automation.

Conclusion

Installing Node.js is more than just running an installer its about setting up a sustainable, scalable, and professional development environment. Whether youre a beginner taking your first steps or an experienced developer managing complex applications, the right installation method and tooling choices make all the difference.

This guide has walked you through installing Node.js on all major operating systems, introduced best practices for version management, highlighted essential tools, and provided real-world examples that reflect industry standards. You now understand how to:

  • Choose between LTS and Current versions
  • Install Node.js using official installers or version managers
  • Use nvm to manage multiple Node.js versions across projects
  • Configure npm, pnpm, and environment variables for optimal performance
  • Debug, monitor, and scale Node.js applications

Remember: the goal isnt just to install Node.js its to create a development environment that grows with you. Use version managers religiously, document your dependencies, and keep your tooling aligned with industry best practices.

With Node.js properly installed and configured, youre ready to build fast, scalable, and modern web applications one line of JavaScript at a time.