The fastest path: install Node.js from the official website or use a version manager like nvm. npm ships bundled with Node.js, so once Node.js is on your machine, npm is ready to use.
- macOS / Linux (recommended):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bashthennvm install --lts - Windows (recommended): Download the LTS installer from nodejs.org and run it — npm is included automatically.
- Verify: Run
node -vandnpm -vin a terminal. Both should return version numbers.
1 Overview
Node.js is a JavaScript runtime built on Chrome’s V8 engine that lets you run JavaScript outside the browser — on servers, in CLIs, and in build tooling. npm (Node Package Manager) is the default package manager for Node.js and the world’s largest software registry, with over 2.1 million published packages.
Because npm is bundled with every official Node.js installer, the practical task is really install Node.js. Once Node.js is installed, npm is available immediately — no separate install required. This guide walks through every supported platform, covers the trade-offs of each method, and ends with verification steps and troubleshooting for the most common issues.
2 Prerequisites
Before you install Node.js and npm, make sure your environment meets the following minimum requirements. None of these are strict blockers — a recent OS and a terminal are enough to get started — but matching these baselines avoids the most common install-time failures.
| Requirement | Minimum | Recommended | Notes |
|---|---|---|---|
| Operating System | Windows 10, macOS 11, Ubuntu 20.04 | Latest LTS of your OS | 64-bit required for official binaries |
| RAM | 2 GB | 8 GB+ | Build-from-source needs more |
| Disk Space | 500 MB | 2 GB | Includes global packages cache |
| Terminal Access | Required | — | PowerShell, Terminal.app, or bash/zsh |
| Internet Connection | Required for install | Broadband | Needed to fetch the installer and packages |
Installing Node.js directly from the website gives you a single, system-wide version. A version manager like nvm (Node Version Manager) lets you install and switch between multiple Node.js versions per project — essential when one repo targets Node 18 and another targets Node 22. The version-manager approach also avoids the notorious EACCES permissions errors caused by system-wide npm install -g.
3 Install Node.js
Node.js ships in two release lines: LTS (Long Term Support, even-numbered, production-ready) and Current (latest features, odd or even). For most users and teams, install the LTS line unless you specifically need a feature only available in Current.
macOS
Intel and Apple Silicon
Option A — Official Installer (simplest)
- Open nodejs.org/en/download and select macOS Installer (.pkg).
- Download the LTS build for your architecture (Apple Silicon = arm64, Intel = x64).
- Double-click the
.pkgfile and follow the installer prompts. - Open Terminal and run
node -vto confirm the install.
Option B — nvm (recommended)
- Install Xcode Command Line Tools:
xcode-select --install - Run the nvm install script:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash - Restart Terminal, then verify:
nvm --version - Install the latest LTS:
nvm install --lts - Set it as default:
nvm alias default 'lts/*'
Option C — Homebrew
- Install Homebrew if missing:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - Install Node.js:
brew install node - Verify:
node -v && npm -v
Windows
Windows 10 / 11 (x64, arm64)
Option A — Official Installer (simplest)
- Go to nodejs.org/en/download and choose Windows Installer (.msi).
- Download the LTS build (x64 for most systems).
- Run the
.msifile and accept the license. - Leave “Automatically install the necessary tools” checked — this installs Python and build tools needed by some native npm packages.
- Open PowerShell and run
node -v.
Option B — nvm-windows (recommended)
- Download nvm-setup.exe from the nvm-windows releases page.
- Run the installer and accept the default install path.
- Open a fresh PowerShell window and run:
nvm install lts - Activate that version:
nvm use lts - Verify:
node -v && npm -v
Option C — winget
- Open PowerShell and run:
winget install OpenJS.NodeJS.LTS - Restart your terminal when the install finishes.
- Verify:
node -v
Linux
Ubuntu / Debian / Fedora / Arch
Option A — nvm (recommended)
- Install build prerequisites (Debian/Ubuntu):
sudo apt update && sudo apt install -y curl build-essential - Run the install script:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash - Reload your shell:
source ~/.bashrc(or~/.zshrc) - Install the latest LTS:
nvm install --lts - Verify:
node -v && npm -v
Option B — NodeSource APT repository
- Fetch the NodeSource setup script for the LTS line (22.x):
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - - Install Node.js:
sudo apt-get install -y nodejs - Verify both tools:
node -v && npm -v
Option C — Distribution package manager
- Ubuntu / Debian:
sudo apt install -y nodejs npm - Fedora:
sudo dnf install -y nodejs npm - Arch:
sudo pacman -S nodejs npm - Verify:
node -v
sudo npm install -gInstalling global packages with sudo places files in system-owned directories and routinely produces EACCES errors when you later try to update or remove them. If you installed Node.js through the system package manager, configure npm’s global prefix to a directory inside your home folder instead:
mkdir ~/.npm-global && npm config set prefix '~/.npm-global'
Then add ~/.npm-global/bin to your PATH. Or simply switch to nvm, which sidesteps the issue entirely.
4 Install npm
Every official Node.js installer and every nvm install ships npm as part of the bundle. Once Node.js is installed, npm is already on your machine — there is no separate npm download step.
What you may want to do separately is update npm to the latest version, switch to a faster package manager like pnpm or Yarn, or configure npm’s global install directory to avoid permission errors.
| Action | Command | When to use |
|---|---|---|
| Check npm version | npm -v |
Confirm what’s installed |
| Update npm (self-update) | npm install -g npm@latest |
Get newest npm features |
| Install pnpm | npm install -g pnpm |
Faster installs, saved disk space |
| Install Yarn | npm install -g yarn |
Alternative registry client |
| Configure global prefix | npm config set prefix '~/.npm-global' |
Avoid EACCES errors |
| List global packages | npm ls -g --depth=0 |
Audit what is installed globally |
For learning and small projects, plain npm is perfectly fine and is the most compatible choice. pnpm is worth adopting once you work in a monorepo or care about install speed and disk usage — it hard-links shared dependencies, so a 200-package install that costs 1.2 GB with npm often costs under 300 MB with pnpm. Yarn (v4) is powerful but adds configuration overhead; pick it if your team already standardizes on it.
5 Verify Installation
After installing, run the three commands below in a fresh terminal window. Each should print a version number with no error. If any command is not found, the install did not complete or your PATH is missing the install directory — see Common Issues below.
- Check Node.js:
node -v— expect something likev22.11.0. - Check npm:
npm -v— expect something like10.9.0. - Check npx:
npx -v— npx runs one-off package binaries without installing them globally.
For a deeper sanity check, create and run a tiny script that prints the Node.js version and a list of installed global packages:
# Create a working directory
mkdir ~/node-hello && cd ~/node-hello
Print versions
node -e "console.log('Node version:', process.version)"
npm -v
Initialize a project and install a package
npm init -y
npm install lodash
node -e "const _ = require('lodash'); console.log(_.chunk([1,2,3,4,5], 2))"
If the final command prints [ [ 1, 2 ], [ 3, 4 ], [ 5 ] ], your Node.js and npm installation is fully working — the runtime can execute code, npm can resolve and install packages from the registry, and modules load correctly.
6 Common Issues
Most install-time problems fall into one of four buckets: command-not-found PATH issues, permission errors on global installs, SSL/TLS errors behind corporate proxies, and version mismatches between Node.js and a project’s lockfile. The table below maps each symptom to its cause and fix.
| Symptom | Cause | Fix |
|---|---|---|
command not found: node or 'node' is not recognized |
Install directory not on PATH | macOS/Linux: add ~/.nvm/versions/node/... or restart shell. Windows: reinstall with the .msi or add C:\Program Files\nodejs\ to PATH. |
EACCES: permission denied on npm install -g |
Global prefix owned by root | Set a user-owned prefix: npm config set prefix '~/.npm-global' and add it to PATH. Better: switch to nvm. |
UNABLE_TO_VERIFY_LEAF_SIGNATURE |
Corporate proxy intercepting HTTPS | Set the proxy env vars (HTTPS_PROXY) and/or npm config set strict-ssl false as a last resort. |
npm ERR! code ERESOLVE peer dependency conflict |
Conflicting package versions in package.json |
Run npm install --legacy-peer-deps or update the offending package to a compatible version. |
| npm install hangs forever | Slow default registry or firewall | Switch registry: npm config set registry https://registry.npmmirror.com (mirror) or check your DNS. |
nvm: command not found after install |
Shell rc file not reloaded | Run source ~/.bashrc (or ~/.zshrc) or open a new terminal window. |
| Node version mismatch between projects | System-wide install is wrong version | Use nvm use <version> per project, or add an .nvmrc file with the target version. |
sudo to fix npm permission errorsIt is tempting to prepend sudo when npm throws a permission error. Do not. sudo npm install -g puts package files under /usr/local/lib/node_modules owned by root, which makes every subsequent global install, update, and uninstall require sudo as well — and breaks tools like npx that try to write to that directory. The correct fix is always to change the install prefix or switch to nvm.
7 Next Steps
With Node.js and npm installed and verified, you have the foundation for everything else in the JavaScript ecosystem. The next moves depend on what you want to build:
Build a Backend API
Express, Fastify, or Hono
Spin up a minimal HTTP server in under a minute and learn routing, middleware, and JSON handling. Express is the most documented option; Fastify is faster and has built-in schema validation.
mkdir my-api && cd my-api && npm init -ynpm install express- Create
index.jswith a singleapp.get('/health', ...)route. node index.js— visithttp://localhost:3000/health.
Build a Frontend App
Vite + React, Vue, or Svelte
Vite is the de-facto frontend build tool — it uses esbuild for dev-server startup in milliseconds and Rollup for production bundles. Every major framework ships a Vite template.
npm create vite@latest my-app -- --template reactcd my-app && npm installnpm run dev— open the printed localhost URL.- Edit
src/App.jsxand watch hot-reload in action.
Automate with CLIs
Build a custom command-line tool
Node.js excels at writing CLIs that shell scripts can’t easily express — JSON parsing, parallel HTTP, and progress bars. Publish your tool to npm and anyone can install it with npm install -g.
npm init -yin a new folder.- Add
"bin": { "mycli": "./cli.js" }topackage.json. - Write
cli.jsstarting with#!/usr/bin/env node. npm linkto test locally, thennpm publishto share.
8 Take Action
You now have everything you need: a clear install path for every major operating system, a verification checklist, and a troubleshooting table for the most common failure modes. The only remaining step is to run the commands on your own machine.
- Open a terminal — Terminal.app on macOS, PowerShell on Windows, or your shell of choice on Linux.
- Install Node.js via nvm — it is the single decision that prevents the most future pain:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install --lts - Verify both tools are working:
node -v && npm -v - Initialize your first project and install a package to confirm the registry is reachable:
mkdir hello-node && cd hello-node && npm init -y && npm install chalk - Pick a direction from Next Steps — backend, frontend, or CLI — and build something small today.
That is the entire install story for Node.js and npm. The runtime is free, the registry is free, and the ecosystem is the largest in the JavaScript world. The fastest way to learn what Node.js can do is to run it — so open a terminal and start now.
Serving Clients Across the US & UK
Dev Station Technology partners with startups, enterprises, and development teams throughout the United States and the United Kingdom. Our Vietnam-based engineering teams offer significant time-zone overlap with both US Eastern/Pacific and UK GMT business hours, ensuring real-time collaboration and faster delivery cycles. We bill in USD and GBP, comply with US regulations (SOC 2, HIPAA) and UK/EU standards (GDPR, ISO 27001), and provide dedicated account management for North American and British clients.
Want an AI assistant to summarize or cite this guide?
Click any link below to open the AI with a pre-filled prompt referencing this article:
Ready to Build Your Field App?
Contact Dev Station Technology to discuss your project requirements and receive a development roadmap within 48 hours.
Get a Quote →


