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.

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.
| Piece | What it does | How to check it |
|---|---|---|
| node | Runs JavaScript files, servers, build tools, and scripts. | node --version |
| npm | Installs packages and runs scripts declared in package.json. | npm --version |
| npx | Runs a package command without treating it as a permanent global tool. | npx --version |
| PATH | Tells the terminal where the node, npm, and npx executables live. | where node (Windows) or command -v node (macOS/Linux) |

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.
| Method | Best for | Trade-off |
|---|---|---|
| Version manager | Development, multiple projects, teams, and easy upgrades or rollbacks. | One extra setup step, then clean user-level installs and fast version switching. |
| Official LTS installer | A first course, one computer, or the shortest path to a single version. | Simple now, but switching versions later is less convenient. |
| Operating-system package manager | Managed machines and developers already comfortable with Homebrew, winget, or a Linux repository. | The available release may differ from the LTS line your project expects. |
Install Node.js and npm on your operating system
- 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.
- 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.
- 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 --version
npm --version
npx --version
where.exe node
where.exe npmVerify 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.
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.
mkdir node-setup-check
cd node-setup-check
npm init -y
npm install picocolors
npm ls picocolors
npm run| Item | Purpose | Commit to Git? |
|---|---|---|
| package.json | Project metadata, scripts, and declared dependency ranges. | Yes |
| package-lock.json | Exact dependency resolution for repeatable installs. | Yes, for applications |
| node_modules/ | Downloaded package contents for this computer. | No; add it to .gitignore |
const pc = require('picocolors');
console.log(pc.green('Node.js and npm are working.'));node index.jsUnderstand the npm commands you will use
| Command | Use it for | Important behavior |
|---|---|---|
| npm install | Install everything declared by the project. | Uses package-lock.json when its resolution still satisfies package.json. |
| npm ci | Clean, 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 outdated | See dependencies with newer releases. | Review compatibility before updating major versions. |
| npm audit | Review known vulnerability reports for the resolved dependency tree. | Read the report; do not apply force fixes blindly. |
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.
nvm ls
nvm install --lts
nvm use --lts
node --version
npm --version# Example only: choose the major your project actually supports
echo 24 > .nvmrc
nvm useFix common installation problems
| Problem | Likely cause | Fix |
|---|---|---|
| node or npm is not recognized | The 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 not | A 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 loaded | The 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 denied | A 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 runs | More 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 build | The 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 machines | Different 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. |
node --version
npm --version
npm config get registry
npm doctor
# Windows: where.exe node && where.exe npm
# macOS/Linux: command -v node && command -v npmNext 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
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.