How to Install Node.js and npm on a Mac
npm comes bundled with Node.js, so installing Node installs npm too. On a Mac you can use the installer from nodejs.org, run brew install node, or use a version manager such as nvm or fnm. A version manager is the safest choice for developers because it avoids permission errors and switches versions per project.
| Method | One-line install | Switch versions? | Best for |
|---|---|---|---|
| Official installer | Download from nodejs.org | No | One version, no terminal setup |
| Homebrew | brew install node | Only via node@24 style formulae | People who already use Homebrew |
| nvm | curl script from the nvm README | Yes | Most projects, widest documentation |
| fnm | brew install fnm | Yes, automatic on cd | Fast shells, .node-version files |
Updated
Every Mac Node.js tutorial picks one method and skips the others, then leaves you stuck when npm complains about permissions. This page puts all four side by side with the commands checked against each project's own docs, a picker that prints only the steps you need, and an error fixer for the messages people hit most.
All methods
Official installer
- Download the macOS installer for the LTS version from nodejs.org and open it.
https://nodejs.org/en/download - Click through the installer, then open a new Terminal window and check both commands.
node -v npm -v - Before installing packages globally, point npm at a folder you own so you never need sudo.
mkdir -p ~/.local npm config set prefix ~/.local echo 'PATH=~/.local/bin:$PATH' >> ~/.profile echo 'source ~/.profile' >> ~/.zprofile source ~/.profile
Homebrew
- Install the newest release, which includes node, npm and npx.
brew install node - Or stay on an LTS line with a versioned formula. Versioned formulae are keg-only, so follow the PATH line brew prints afterwards.
brew install node@24 - Check the result in a new Terminal window.
node -v npm -v which node
nvm
- Run the install script from the nvm README (v0.40.8 at the time of writing; the README always shows the latest).
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash - Open a new Terminal window, then install the latest LTS and make it the default.
nvm install --lts nvm alias default 'lts/*' - Pin a version per project with a .nvmrc file and switch to it with nvm use.
echo "24" > .nvmrc nvm use node -v
fnm
- Install fnm with Homebrew.
brew install fnm - Add the shell setup line to ~/.zshrc so fnm loads and switches versions when you change folders.
echo 'eval "$(fnm env --use-on-cd --shell zsh)"' >> ~/.zshrc source ~/.zshrc - Install the latest LTS and check it.
fnm install --lts node -v npm -v
Error fixer
EACCES: permission denied
npm tried to write to a system folder. Do not use sudo. Either switch to nvm or fnm, or set npm's prefix to ~/.local as shown in the installer steps, then reinstall the global package.
command not found: node or npm
The shell cannot find the binary. Open a new Terminal window first. If it still fails, run which node, and check that the PATH line from Homebrew or the setup line from your version manager is in ~/.zshrc.
command not found: nvm
nvm is a shell function loaded by lines the installer adds to your profile. Open a new window, or make sure ~/.zshrc exists before running the installer, then run it again.
Unsupported engine or wrong Node.js version
The package asks for a different Node.js version than the one running. Check node -v, install the version the project needs, and pin it with .nvmrc or .node-version.
EADDRINUSE: address already in use
Node.js works; another process already holds the port. See the localhost:3000 guide for the commands that find and stop it.
Node.js release lines in October 2026
| Version | Codename | Status |
|---|---|---|
| v26 | None yet | Current |
| v24 | Krypton | LTS |
| v22 | Jod | LTS |
| v20 | Iron | End of life |
Everyday version manager commands
nvm
List what is installed, install another version, and switch the current shell to it.
nvm ls # installed versions
nvm install 22 # add the latest v22
nvm use 22 # switch this shell
nvm alias default 24fnm
The same tasks with fnm. With --use-on-cd in your shell setup, entering a folder that has .node-version or .nvmrc switches for you.
fnm list
fnm install 22
fnm use 22
fnm default 24
Installer, Homebrew or a version manager?
The installer is the least work if you need one version for a course or a single tool. It puts node and npm in system folders, which is why global installs can later fail with EACCES.
Homebrew keeps Node with your other command line tools and updates it with brew upgrade. Its main formula tracks the newest release, so use a versioned formula such as node@24 if you want to stay on LTS.
nvm and fnm install each version inside your home folder, so npm never needs sudo, and you can switch versions per project. For development work this is the method that causes the fewest problems.
Checking the install
Open a new Terminal window after installing, then run node -v and npm -v. Each should print a version number. which node shows the folder the shell found it in, which tells you which install is active.
If which node points at /usr/local/bin or /opt/homebrew/bin while you expected a version manager, the shell setup line for nvm or fnm has not run. Check your ~/.zshrc.
How it works
- Choose a method in the picker. The steps for that method appear with copy buttons.
- Run the commands in Terminal, one block at a time.
- Run the verify commands to confirm node and npm both answer with a version number.
- If something fails, paste the error into the error fixer to see the likely cause and the fix.
Tips
- Pick one method and stick to it. Two installs on the same Mac lead to which node pointing somewhere unexpected.
- Never run npm install -g with sudo. Fix the folder npm writes to, or use a version manager, instead.
- Commit a .nvmrc or .node-version file to each project so everyone on the team runs the same major version.
- Use an LTS line for anything you deploy. Current releases are for trying new features.
Frequently asked questions
Does installing Node.js install npm?
Yes. The official installer, the Homebrew formula and both version managers install npm and npx alongside node. You do not need a separate npm download.
Which Node.js version should I install?
The latest LTS line. On nodejs.org in October 2026 that is v24 (Krypton), with v26 still in its Current phase. Frameworks such as Vite and Next.js also publish a minimum version, so check their docs if you use them.
What does LTS mean?
Long Term Support. A release spends about six months as Current, then moves to Active LTS for bug and security fixes, then Maintenance LTS for critical fixes only. The Node.js site says that from version 27 every major release will become LTS, not only the even ones.
Can I install nvm with Homebrew?
The nvm README says a Homebrew install of nvm is not supported and asks you to use its install script instead. fnm, on the other hand, documents brew install fnm as a normal install path.
How do I uninstall a Homebrew Node.js?
Run brew uninstall node. If you are moving to a version manager, do this first so the old binary does not shadow the new one on your PATH.
Related: npm commands cheat sheet, pnpm vs npm, Fix localhost:3000, Git cheat sheet, Vite vs Next.js.
Build your site free or see all free tools. On We.Inc you can build your site free, with no card and no trial needed to start. AI building is on paid plans from $19 a month.
More in Guides
- Invoice Template in Google Docs: Make One in Minutes
- Accessible JavaScript Accordion and Tabs
- JavaScript Array Methods Cheat Sheet (Live)
- JavaScript Promises, Async/Await and Fetch
- JavaScript Date Format: Builder and Examples
- JavaScript Event Listeners: Click, Submit, Scroll and Delegation
- localStorage in JavaScript (with Working Examples)
- The JavaScript For Loop, and Which Loop to Use
Related guides
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App