# How to Install Node.js on Windows, macOS and Linux (with nvm)

**How to install Node.js on Windows**: download the LTS Windows Installer (.msi) from nodejs.org, run it with the default options (keep "Add to PATH" enabled), then open a new terminal and run `node -v` and `npm -v`. npm is included, so no separate download is needed. macOS and Linux work the same way, or through nvm.

## What Node.js and npm are

 Node.js is a JavaScript runtime that runs outside the browser. It powers back-end apps and APIs, and it is also what front-end build tools, linters, test runners and countless command-line utilities run on. Even if you only write front-end code, you will need Node.js to build a modern project or start its dev server.

 npm is the package manager bundled with the official Node.js distribution. The installer puts three commands on your system: `node` (the runtime), `npm` (installs packages) and `npx` (runs a package without installing it globally).

## Which Node.js version to download: LTS or Current

 LTS (Long Term Support)Current Best forReal projects, servers, courses, CITrying new language and API features Support windowLong: active support, then a security-fix-only maintenance periodShort: until the next release line takes over Package compatibilityHighest — library authors test against LTS firstSome packages with native add-ons may fail to build RecommendationInstall by defaultInstall as a second version through a version manager Which version numbers are LTS right now, and which have reached end of life, is listed on the official [Node.js Releases](https://nodejs.org/en/about/previous-releases) page. Those numbers change every year, so trust that page over any tutorial. If a project pins a version (an `engines` field in `package.json` or an `.nvmrc` file in the repo root), install exactly that one.

## How do I download Node.js for Windows?

 Go to [nodejs.org/en/download](https://nodejs.org/en/download), pick the version, the operating system and the architecture (x64 for most PCs, ARM64 for Windows on Arm laptops) and download the Windows Installer (.msi). The same page offers a Standalone Binary (.zip) and shows ready-made commands for version managers. Avoid third-party mirrors: Node.js is free, and a tampered installer is an easy way to compromise a developer machine.

 Every release ships a `SHASUMS256.txt` file. Compare the hash of your download against it:

```
`# Windows, cmd certutil -hashfile node-v<version>-x64.msi SHA256 # Windows, PowerShell Get-FileHash .\node-v<version>-x64.msi -Algorithm SHA256 # macOS shasum -a 256 node-v<version>.pkg # Linux sha256sum node-v<version>-linux-x64.tar.xz`
```

## Can I install Node.js on Windows 11?

 Yes. The steps for Windows 11 and Windows 10 are identical. You have three options.

### Official .msi installer

 - Run the downloaded .msi and accept the license.
 - Keep the default location, `C:\Program Files\nodejs\`.
 - On the Custom Setup screen, leave npm and "Add to PATH" enabled — the latter is what makes `node` and `npm` available in every terminal.
 - The "Tools for Native Modules" checkbox is optional. It installs Chocolatey, Python and the Visual Studio build tools, which only matter for packages that compile native code. You can add them later if you need them.
 - Click Install and confirm the UAC prompt.
 - Close every open terminal and editor window and open a new one. Windows that were already open keep the old PATH.

### winget from PowerShell or cmd

```
`winget search OpenJS.NodeJS winget install OpenJS.NodeJS.LTS`
```

 Check the package ID in the search output before installing. Updates later are `winget upgrade OpenJS.NodeJS.LTS`. New to the console? See our [Windows command line guide](/en/articles/windows-command-line-guide).

### ZIP archive without admin rights

 Extract the Standalone Binary (.zip) into a folder you own, such as `C:\Users\<name>\node`, then add that folder to your user PATH: Settings → System → About → Advanced system settings → Environment Variables → Path → Edit → New. This copy never updates itself.

## How do I install Node.js in my terminal?

 From the terminal, the cleanest route on macOS and Linux is nvm (Node Version Manager). It installs Node.js into your home directory, lets you switch versions per project, and removes the need for `sudo` when installing global packages. Copy the install command from the [nvm-sh/nvm README](https://github.com/nvm-sh/nvm) — it contains the current script version and looks like this:

```
`curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash`
```

 Close and reopen the terminal, then:

```
`command -v nvm # prints: nvm nvm ls-remote --lts # available LTS versions nvm install --lts # install the latest LTS nvm use --lts # switch to it nvm alias default 'lts/*' # use LTS in new shells nvm ls # installed versions`
```

 With an `.nvmrc` file in the project root, plain `nvm install` and `nvm use` read the version from it.

 On Windows, nvm-sh does not work; use the separate [nvm-windows](https://github.com/nvm-windows/nvm) project. Uninstall any .msi-installed Node.js first, install the `*-setup.exe` for your architecture (x64 or arm64) from the Releases page, then:

```
`nvm list available nvm install lts nvm list nvm use <version from nvm list>`
```

 nvm-windows 2.x needs no administrator rights: by default it switches versions through shims rather than symlinks in a system folder. Run its installer from your own account, not as Administrator. The symlink and the admin prompt belonged to the 1.x line.

 Other terminal routes: `brew install node` on macOS (installs Homebrew's latest formula, which is not necessarily LTS), and on Debian/Ubuntu either the distro package (`sudo apt install nodejs npm`, usually older than the current LTS) or the NodeSource repository:

```
`curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt install -y nodejs`
```

 Read any script before piping it into `bash`. If you are setting up a fresh machine, you will also want to [install Git](/en/articles/git-install-guide).

 MethodOSMultiple versionsAdmin rightsChoose it when .msi / .pkg installerWindows, macOSNoYesOne machine, one version, fastest start wingetWindowsNoYesScripted PC setup, updates from the console HomebrewmacOSLimitedNoYour other tools already come from brew NodeSource / distro packageLinuxNoYesServers: one system-wide version for all services nvm / nvm-windowsAllYesNo (nvm-windows 2.x included)Developer workstation with several projects

## Does installing Node.js also install npm?

 Yes, with the official installer, winget, Homebrew, nvm and NodeSource. The exception is distributions that split npm into its own package, such as Ubuntu's `apt install npm`. Verify all three tools in a new terminal:

```
`node -v npm -v npx -v`
```

 To see which binary actually runs, use `where node` (cmd), `Get-Command node` (PowerShell) or `which node` (macOS/Linux). Two paths from `where node` mean two installs are fighting over PATH — remove one. In VS Code, Node.js is not installed separately: the editor uses the system copy, so restart VS Code after installing and check `node -v` in its integrated terminal.

## Common installation errors

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

 In PowerShell the same problem reads `The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program`. The folder with node.exe is not in the PATH of that window. Open a new terminal first; if it persists, check `$env:Path -split ';'` for `C:\Program Files\nodejs\` and re-run the .msi (Repair) if it is missing.

### npm.ps1 cannot be loaded because running scripts is disabled

 PowerShell runs npm through `npm.ps1`, and the default execution policy on Windows client editions blocks scripts. Use cmd, call `npm.cmd`, or allow local and signed scripts for your own account:

```
`Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`
```

### EACCES when running npm install -g

 npm is trying to write to a system directory. Do not fix it with `sudo npm install -g` — that runs package install scripts as root. Switch to nvm, or follow the [npm documentation](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally) and move the global prefix to your home directory:

```
`mkdir -p ~/.npm-global npm config set prefix '~/.npm-global' echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile source ~/.profile`
```

## How to update Node.js and npm

 - Installer: download the new version and install over the old one.
 - winget: `winget upgrade OpenJS.NodeJS.LTS`. Homebrew: `brew upgrade node`.
 - nvm: `nvm install --reinstall-packages-from=current 'lts/*'` installs the newest LTS and carries over global packages.
 - npm only: `npm install -g npm@latest` (from an Administrator terminal if Node.js lives in Program Files).

 After a major version change, delete `node_modules` and run `npm ci`: native add-ons are compiled for one Node.js version and fail with `was compiled against a different Node.js version` otherwise.

## Running Node.js on a web server

 An app started with `node server.js` in an SSH session dies with the session and does not come back after a reboot. A production setup has three parts: a system-wide Node.js (NodeSource or the distro package — nvm installs per user, so a systemd service running as another user will not find it), a process manager (systemd or pm2) and a [reverse proxy](/en/articles/reverse-proxy-explained) such as nginx in front, terminating TLS and forwarding to a local port:

```
`location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }`
```

 With pm2: `pm2 start server.js --name myapp`, then `pm2 startup` (run the command it prints with sudo) and `pm2 save`.

 If the site returns 502 right after a deploy, nginx is up but nothing answers on the upstream port; the nginx error log shows `connect() failed (111: Connection refused) while connecting to upstream`. Check `pm2 logs` or `journalctl -u myapp -n 50`, `sudo ss -ltnp | grep 3000` and `curl -I http://127.0.0.1:3000/`. Usual causes: the app crashed on start (new Node.js major, stale `node_modules`, a missing environment variable), it listens on a different port, or it bound to `::1` because the code says `localhost` while nginx connects to `127.0.0.1`. More scenarios in our [502 Bad Gateway guide](/en/articles/http-502-bad-gateway-fix).

## How to check your Node.js site from outside

 `curl` on the server does not show what visitors get through DNS, the proxy and the certificate. After a deploy, check the public URL:

 - [HTTP header check](/en) — the status code and headers the site actually returns, so a 502 from the proxy is obvious.
 - [SSL check](/en/ssl) — the certificate nginx serves in front of the app: expiry and domain match.

## Frequently asked questions

### Which Node.js version should a beginner install?

 The latest LTS. Tutorials, frameworks and packages target it. Add Current later through nvm if you need a specific new feature.

### Can I install Node.js without admin rights?

 Yes: the .zip Standalone Binary plus a user PATH entry on Windows, or nvm on macOS and Linux.

### How do I uninstall Node.js completely?

 On Windows, remove it from Installed apps, then delete leftover `%AppData%\npm` and `%LocalAppData%\npm-cache` folders. With nvm, run `nvm uninstall <version>`; with Homebrew, `brew uninstall node`.

### Does Node.js run on Windows 7?

 Current Node.js releases do not support Windows 7. Supported platforms are listed in BUILDING.md in the nodejs/node repository.

### Is nvm the same as NVMe?

 No. nvm manages Node.js versions; NVMe is a storage interface for SSDs and has nothing to do with Node.js.

---

Source: https://enterno.io/en/articles/node-js-install-guide
