SovranCode
Learn
Learn on SovranCodeCourses7 free learning paths→ExercisesPractice with live challenges→GuidesDirect answers for developers→E-booksFocused field guides→
Build
Build on SovranCodeTemplatesSovranCode team marketplace→Developer toolsFast browser utilities→
Connect
Connect on SovranCodeForumQuestions and discussions→JournalPractical development notes→AboutWhy SovranCode exists→PricingFree, Plus, and Student Plus→
Services
SearchCreate account
Explore SovranCodeLearn, practice, and build.
LearnCourses7 free learning paths→ExercisesPractice with live challenges→GuidesDirect answers for developers→E-booksFocused field guides→
BuildTemplatesSovranCode team marketplace→Developer toolsFast browser utilities→
ConnectForumQuestions and discussions→JournalPractical development notes→AboutWhy SovranCode exists→PricingFree, Plus, and Student Plus→
Search
Guides/Developer Setup/How to Install Node.js and npm: Complete Setup Guide
All guides
How-to guide

How to Install Node.js and npm: Complete Setup Guide

Install Node.js and npm correctly on Windows, macOS, or Linux, verify your setup, create a first project, and fix the most common PATH and permission problems.

Beginner 20 min readUpdated September 17, 2026
WindowsmacOSLinux
A modern development workspace with an abstract green module network and terminal
01 Install LTS 02 Verify PATH 03 Build
QUICK ANSWER

For most developers, install the current Node.js LTS release with a version manager, then open a new terminal and run node --version and npm --version. npm is bundled with Node.js, so you normally do not install it separately. Use the official LTS installer when you want the shortest one-time setup; use a version manager when projects may require different Node.js versions.

What Node.js and npm install

Node.js is a JavaScript runtime: it lets your computer execute JavaScript outside a web browser. npm is the package manager and command-line client distributed with Node.js. It reads a project's package.json file, downloads dependencies into node_modules, and records exact dependency versions in package-lock.json.

The four pieces of a working Node.js setup
PieceWhat it doesHow to check it
nodeRuns JavaScript files, servers, build tools, and scripts.node --version
npmInstalls packages and runs scripts declared in package.json.npm --version
npxRuns a package command without treating it as a permanent global tool.npx --version
PATHTells the terminal where the node, npm, and npx executables live.where node (Windows) or command -v node (macOS/Linux)
npm comes with Node.js

A normal Node.js installation includes a compatible npm version. Install Node.js first; only update npm separately when a project or a documented npm fix requires it.

An abstract installation flow from a JavaScript runtime through a package manager into a project folder and installed dependencies
Node.js runs the code; npm moves declared packages into a project-local dependency tree.

Choose LTS, Current, and an installation method

Choose the release line before choosing a download. LTS (Long-Term Support) is the dependable default for tutorials, frameworks, team projects, and production applications. Current is useful for testing new platform features, but it has a shorter support window and can be ahead of framework or native-package support.

Pick the method that fits your work
MethodBest forTrade-off
Version managerDevelopment, multiple projects, teams, and easy upgrades or rollbacks.One extra setup step, then clean user-level installs and fast version switching.
Official LTS installerA first course, one computer, or the shortest path to a single version.Simple now, but switching versions later is less convenient.
Operating-system package managerManaged machines and developers already comfortable with Homebrew, winget, or a Linux repository.The available release may differ from the LTS line your project expects.
Use the version the project declares

If a repository contains .nvmrc, .node-version, or a package.json engines field, follow it instead of choosing the newest release. Matching the team prevents hard-to-explain build and dependency differences.

Do not keep two unmanaged installations

A version manager plus an old system installer can place multiple node commands on PATH. Remove or disable the method you no longer use, then confirm which executable the terminal finds.

Install Node.js and npm on your operating system

  1. 01

    Choose a Windows route

    For one LTS version, download the Windows Installer (.msi) from nodejs.org and keep npm and Add to PATH selected. For project work that needs version switching, install a Windows-compatible Node version manager and use its documented setup.

  2. 02

    Install the LTS release

    Use the LTS option rather than Current unless your project explicitly asks for Current. Complete the installer with the default destination; administrator approval may be required for the machine-wide installer.

  3. 03

    Restart your terminal and editor

    Close PowerShell, Command Prompt, Windows Terminal, and any open editor terminals. A fresh process is required to read the updated PATH.

Official and recommended downloads

Node.js downloadsChoose the LTS Windows installer or review current installation options.npm installation guidancenpm recommends a version manager and lists Windows-compatible choices.
Verify Node.js on Windows
node --version
npm --version
npx --version
where.exe node
where.exe npm
Optional winget route

If you manage software with winget, install the package whose ID is OpenJS.NodeJS.LTS. Check the package details before confirming, then restart the terminal and run the verification commands above.

Verify Node.js, npm, npx, and PATH

Version output proves the commands start; the executable-location check proves which installation is running. Run both in the same terminal and editor you will use for development.

PowerShell or Command Prompt
node --version
npm --version
npx --version
where.exe node
where.exe npm
node -e "console.log('Node.js is ready')"

Your base installation is healthy when

  • node --version prints a supported version, ideally from the project's declared release or the current LTS line.
  • npm --version and npx --version both print versions without an error.
  • The executable path points to the installation method you intended to use.
  • The one-line JavaScript command prints Node.js is ready.
  • The same checks work inside your code editor's integrated terminal.

Create a first npm project

A real project check is more useful than version output alone. The commands below create a folder, generate package.json without an interview, add a small dependency, and show npm's dependency tree.

Create and inspect a test project
mkdir node-setup-check
cd node-setup-check
npm init -y
npm install picocolors
npm ls picocolors
npm run
Files npm creates and what to do with them
ItemPurposeCommit to Git?
package.jsonProject metadata, scripts, and declared dependency ranges.Yes
package-lock.jsonExact dependency resolution for repeatable installs.Yes, for applications
node_modules/Downloaded package contents for this computer.No; add it to .gitignore
index.js
const pc = require('picocolors');

console.log(pc.green('Node.js and npm are working.'));
Run the file
node index.js
Local dependencies are the default

Use npm install package-name inside a project. Reserve global installation for true command-line tools, and prefer npx or npm exec when you only need to run a tool occasionally.

Understand the npm commands you will use

Everyday npm command reference
CommandUse it forImportant behavior
npm installInstall everything declared by the project.Uses package-lock.json when its resolution still satisfies package.json.
npm ciClean, repeatable installs in CI or from an existing lockfile.Requires a lockfile and replaces the existing node_modules directory.
npm install <name>Add a runtime dependency.Updates package.json and package-lock.json.
npm install -D <name>Add a development-only tool.Records it under devDependencies.
npm run <script>Run a command declared under scripts in package.json.Project-local binaries are added to PATH for that script.
npm outdatedSee dependencies with newer releases.Review compatibility before updating major versions.
npm auditReview known vulnerability reports for the resolved dependency tree.Read the report; do not apply force fixes blindly.
npm install is not the same as npm ci

Use npm install while intentionally adding or changing dependencies. Use npm ci when package.json and package-lock.json are already committed and you want the exact locked tree, especially in automated builds.

Switch versions and update safely

Node.js and npm have separate release schedules. A supported Node.js release already includes a compatible npm version, so update the runtime first and update npm independently only when necessary.

Common nvm version workflow
nvm ls
nvm install --lts
nvm use --lts
node --version
npm --version
Pin the project's intended Node major
# Example only: choose the major your project actually supports
echo 24 > .nvmrc
nvm use
Do not chase latest blindly

Before changing Node.js or npm in an existing repository, read its engines field, CI configuration, deployment runtime, and framework support policy. A successful local upgrade can still fail in production when those environments use a different major version.

Fix common installation problems

Start with the exact symptom
ProblemLikely causeFix
node or npm is not recognizedThe terminal has an old PATH or installation did not add its bin directory.Close every terminal and editor, reopen one, then check where.exe or command -v. Reinstall only if no executable is found.
node works but npm does notA partial install, broken PATH entry, or conflicting installation.Check both executable paths. Repair the installer or reinstall through one version manager; do not download npm from an unrelated website.
PowerShell says npm.ps1 cannot be loadedThe current PowerShell execution policy blocks the npm wrapper script.Use npm.cmd temporarily, or review a CurrentUser execution-policy change with your organization before applying it.
EACCES or permission deniedA global package directory is owned by another user or root.Do not add sudo. Move to a user-level version manager and reinstall the tool there.
The wrong Node.js version runsMore than one installation appears on PATH.List every executable, remove the stale installer or PATH entry, then start a fresh terminal.
A native package fails to buildThe package needs platform build tools or does not support your Node.js major.Read the first build error, check the package's supported Node versions, and install the documented compiler tools only if required.
npm install behaves differently on two machinesDifferent Node versions, a changed lockfile, or inconsistent registry configuration.Match the project version, commit package-lock.json, use npm ci, and compare npm config get registry.
Useful diagnostics to include in a bug report
node --version
npm --version
npm config get registry
npm doctor
# Windows: where.exe node && where.exe npm
# macOS/Linux: command -v node && command -v npm
Reinstall last, diagnose first

Most setup failures come from a stale terminal, two competing installations, or a project that expects another Node.js major. The version and path commands identify all three faster than repeated reinstalls.

Next steps after installation

A practical setup to keep

  • Use an active LTS release unless the project documents another version.
  • Commit package.json and package-lock.json; ignore node_modules.
  • Prefer project-local packages and npm scripts over unexplained global tools.
  • Use npm ci in continuous integration and other reproducible environments.
  • Check package names, maintainers, release activity, and install scripts before adding dependencies.
  • Match the Node.js version used by your hosting or deployment platform before shipping.

Continue with official documentation

Node.js LearnOfficial introductions to the runtime, modules, asynchronous work, and diagnostics.npm package installationHow local dependency installation works.npm CLI documentationReference for install, ci, run, audit, configuration, and more.

Frequently asked questions

Does installing Node.js install npm too?

Yes. Standard Node.js installers and version managers install npm with Node.js. Verify both with node --version and npm --version.

Which Node.js version should a beginner install?

Install the current LTS release unless your course, repository, framework, or hosting platform specifies another version. LTS is the broadest compatibility target for most learners and production projects.

Should I use a Node.js installer or a version manager?

Use a version manager for ongoing development or multiple projects. The official LTS installer is fine for a simple one-version setup, but switching or removing versions is less convenient later.

Do I need to install npm separately?

Usually no. npm ships with Node.js. Update it separately only when you need a particular supported npm release or a documented fix.

What is the difference between npm and npx?

npm installs packages and runs package.json scripts. npx, implemented through npm exec in modern npm, runs a package command and is useful when you do not want a permanent global installation.

Why is npm not recognized after installation?

The open terminal probably has the old PATH, or another installation is conflicting with the new one. Restart terminals and editors, then use where.exe npm on Windows or command -v npm on macOS and Linux.

Should I run npm with sudo on macOS or Linux?

No for a normal development setup. Repeated permission errors are a sign to use a user-level Node version manager or correct the installation ownership, not to make npm run as root.

Should node_modules be committed to Git?

No. Commit package.json and package-lock.json, add node_modules to .gitignore, and recreate dependencies with npm ci or npm install.

How do I update Node.js?

With a version manager, install and select a newer supported release, test the project, then update its version file. With an installer, download a newer LTS installer from nodejs.org. Check project and deployment compatibility before changing major versions.

Can Node.js and npm be installed without administrator access?

Often yes when a user-level version manager is supported by your operating system and organization. A machine-wide installer may require administrator approval.

On this page
What Node.js and npm installChoose LTS, Current, and an installation methodInstall Node.js and npm on your operating systemVerify Node.js, npm, npx, and PATHCreate a first npm projectUnderstand the npm commands you will useSwitch versions and update safelyFix common installation problemsNext steps after installationFAQ
CONTINUE LEARNING

Put the answer to work.

COURSEJavaScript courseE-BOOKJavaScript: From Values to Applications
RELATED GUIDES

Keep moving.

Browse all guides
How-to guideBeginner

How to Install Python: A Safe Setup Guide

Install a current Python release on Windows, macOS, or Linux; prove which interpreter and pip you are using; create an isolated project environment; and fix the common setup failures without damaging your system Python.

18 min readUpdated Sep 2026
Open guide
How-to guideBeginner

How to Install PostgreSQL: Complete Local Setup

Install PostgreSQL on Windows, macOS, or Linux, create a local database for your app, verify it, and handle the setup details that matter.

18 min readUpdated Sep 2026
Open guide
SOURCES

Official documentation

  • Node.js — Download Node.js
  • Node.js — Release schedule
  • Node.js — Learn
  • npm Docs — Install Node.js and npm
  • npm Docs — Install packages locally
  • npm Docs — npm install
  • nvm — Installation and updating
THE SOVRANCODE PLATFORM

Learn enough to build something real.

Start learning
SovranCode

A free-first programming platform for people who learn best by understanding, practicing, and building.

● Core learning content is free
FollowYouTubePinterestX
LearnHTML courseCSS courseJSJavaScript coursePython courseC courseSQL courseGit courseDeveloper guidesAll exercises
BuildTemplate marketBuyer libraryTemplate licensesDeveloper toolsE-books
CommunityForumJournalContact
CompanyPricing previewAboutServicesPrivacyEnglish edition. Additional languages will be published only after full editorial review.
© 2026 SovranCode · Built for curious minds.Next.js · Node.js · PostgreSQL