General • Beginner • 6 min read

Install and Configure Node.js and NPM Environment

Summary

Step-by-step procedure to install Node.js Long Term Support (LTS), configure npm package manager, and set up environment paths on Windows and Linux.

Companion Tool
JSON Formatter, Validator & Minifier

Free online JSON formatter, beautifier, and validator. Inspect syntax errors, clean ugly payloads, minify JSON strings, and format with custom indentations.

Open tool

Overview

Node.js is an open-source, cross-platform JavaScript runtime environment built on the Google V8 engine. It executes JavaScript outside the web browser, allowing developers to build command-line utilities, APIs, web servers, and modern frontend application toolchains.

When installing Node.js, you also receive npm (Node Package Manager), the default package registry client used to manage dependencies and executable scripts.


Step 1: Choosing Between LTS and Current

The Node.js release schedule offers two distinct release channels:

  • LTS (Long Term Support) Recommended: Designated with even major numbers (e.g., v20, v22). LTS releases receive 30 months of active maintenance and critical security patches. Always use LTS for production, enterprise, and standard development environments.
  • Current: Contains active development features, modern ECMAScript proposals, and experimental APIs. Recommended only if testing cutting-edge runtime features.

Step 2: Installation on Windows

Method A: Official MSI Installer (Simplest)

  1. Download the Windows Installer (.msi) 64-bit LTS package from nodejs.org.
  2. Run the installer and accept the license terms.
  3. Keep the default destination path: C:\Program Files\nodejs\.
  4. In the Custom Setup screen, ensure all components are checked:
    • Node.js runtime
    • corepack (package manager manager)
    • npm package manager
    • Add to PATH (ensures node and npm are available in your command terminal)
  5. In the Tools for Native Modules step, you may leave the Chocolatey / Visual Studio build tools unchecked unless you intend to compile C++ native addons (node-gyp).
  6. Complete the setup wizard.

Method B: Using Windows Package Manager (winget)

Open Windows Terminal or PowerShell and run:

winget install OpenJS.NodeJS.LTS

Step 3: Verification of Environment Paths

Restart your terminal window to ensure the updated system PATH environment variable is reloaded. Run the following verification commands:

node -v
npm -v

Expected output:

v22.12.0
10.9.0

To verify where the binary is installed:

# In PowerShell:
Get-Command node

# In Command Prompt:
where node

Step 4: Configuring Global NPM Directories

By default on Windows, npm installs global packages into %APPDATA%\npm. Verify that this directory exists and is present in your user PATH:

npm config get prefix

If you need to update npm to the latest version independently of the Node.js installer:

npm install -g npm@latest

Troubleshooting Common Errors

'node' is not recognized as an internal or external command

  • Cause: The Node.js binary directory was not appended to the system PATH environment variable.
  • Fix: Open System Properties > Environment Variables. Under System Variables, locate Path, click Edit, and add C:\Program Files\nodejs\. Restart your terminal.

EACCES: permission denied when installing global packages

  • Cause: Permissions error writing to system-protected directories.
  • Fix: On Windows, run your terminal as Administrator, or configure a custom npm global directory inside your user profile folder using npm config set prefix "%USERPROFILE%\.npm-global".

Related reference