How to Install Node.js on Windows, Mac, and Linux
Node.js is one of the most widely used JavaScript runtimes in web development. Whether you're setting up a local development environment, running build tools, or building server-side applications, installing Node.js correctly is the foundation everything else depends on. The process is straightforward — but there are meaningful choices along the way that affect how flexible and maintainable your setup will be.
What Is Node.js and Why the Install Method Matters
Node.js is a runtime environment that lets you run JavaScript outside the browser — on your machine, on a server, or inside automated pipelines. It comes bundled with npm (Node Package Manager), which is how most developers install JavaScript libraries and tools.
The reason the install method matters isn't complexity — it's control. Installing Node.js directly from the official installer is fast, but it makes switching between versions harder. For developers who work across multiple projects with different Node requirements, that rigidity creates real friction over time.
The Three Main Ways to Install Node.js
1. Official Installer (Simplest Path)
The Node.js website (nodejs.org) offers pre-built installers for Windows, macOS, and common Linux distributions. You'll see two versions on the download page:
- LTS (Long-Term Support): Stable, maintained for several years. Best for most users and production work.
- Current: Latest features, updated frequently. Better suited to developers who want to experiment with new capabilities.
For most people getting started, LTS is the right choice — it's stable, well-documented, and widely compatible with npm packages.
On Windows: Download the .msi installer, run it, and follow the prompts. Node and npm are added to your system PATH automatically.
On macOS: Download the .pkg installer and run it. Same result — Node and npm become available globally in your terminal.
On Linux: The process varies by distribution. The Node.js site provides install scripts and package manager instructions for Debian/Ubuntu (apt), Red Hat/Fedora (dnf), and others.
2. Node Version Manager — nvm (Recommended for Developers) 🛠️
nvm (Node Version Manager) is a command-line tool that lets you install, switch between, and manage multiple versions of Node.js on the same machine. It's the preferred method for most active developers.
Why it matters:
- Different projects often require different Node versions
- You can switch versions with a single command (
nvm use 18, for example) - Avoids permission issues common with global npm installs
- Makes upgrades and rollbacks clean
nvm is available for macOS and Linux. Windows users have a separate tool called nvm-windows, which works similarly but is a distinct project.
Basic nvm workflow:
- Install nvm using the official install script from the nvm GitHub repository
- Restart your terminal
- Run
nvm install --ltsto install the latest LTS version - Run
nvm use --ltsto activate it - Confirm with
node -vandnpm -v
3. Package Managers (Homebrew, Chocolatey, winget)
System package managers offer another path, particularly on macOS and Windows.
| Tool | Platform | Command |
|---|---|---|
| Homebrew | macOS / Linux | brew install node |
| Chocolatey | Windows | choco install nodejs-lts |
| winget | Windows | winget install OpenJS.NodeJS.LTS |
These are convenient if you already use a package manager for other software. The downside is version flexibility — switching between Node versions requires more manual steps compared to nvm.
Verifying Your Installation
After installing, open a terminal (Command Prompt, PowerShell, or your shell of choice) and run:
node -v npm -v Both commands should return version numbers. If they do, Node.js is installed and accessible. If you get a "command not found" error, the most common cause is that Node wasn't added to your PATH — this can happen with some manual install methods and usually requires a terminal restart or manual PATH configuration.
Variables That Affect Which Method Works Best for You 🔧
No single install method suits every situation. Several factors shift the calculus:
- Operating system: nvm behaves differently on Windows vs. macOS/Linux. nvm-windows is a solid alternative, but not identical.
- Technical comfort level: The official installer requires no command-line knowledge. nvm requires basic terminal familiarity.
- Number of projects: Single-project developers rarely need version switching. Developers working across multiple codebases benefit significantly from nvm.
- Existing tooling: If you already use Homebrew or Chocolatey, installing Node through those keeps your environment consistent.
- Team or organizational requirements: Some teams standardize on specific Node versions via
.nvmrcfiles — in those environments, nvm becomes effectively required.
Common Post-Install Considerations
Once Node is installed, a few practical points come up quickly:
- npm vs. npx: npm installs packages; npx (included with npm) runs packages without installing them globally — useful for one-off tools.
- Global vs. local packages: Installing packages globally (
npm install -g) makes them available everywhere but can create version conflicts. Most tools recommend local installs per project. - Node version in CI/CD: If you're deploying code, the Node version on your local machine should match what your build environment uses. nvm's
.nvmrcfile makes this easier to enforce.
How Your Setup Shapes the Right Path
A developer building a single personal project on a Mac, comfortable with the terminal, and working in a team that uses .nvmrc files is in a very different position than someone setting up Node for the first time on Windows to run a build tool or follow a tutorial. Both can install Node.js successfully — but the method that gives each person the most control and the fewest headaches depends entirely on how their environment is configured and how they expect to use Node going forward.