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.

Four ways to install, compared
MethodOne-line installSwitch versions?Best for
Official installerDownload from nodejs.orgNoOne version, no terminal setup
Homebrewbrew install nodeOnly via node@24 style formulaePeople who already use Homebrew
nvmcurl script from the nvm READMEYesMost projects, widest documentation
fnmbrew install fnmYes, automatic on cdFast 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

  1. Download the macOS installer for the LTS version from nodejs.org and open it.
    https://nodejs.org/en/download
  2. Click through the installer, then open a new Terminal window and check both commands.
    node -v
    npm -v
  3. 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

  1. Install the newest release, which includes node, npm and npx.
    brew install node
  2. 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
  3. Check the result in a new Terminal window.
    node -v
    npm -v
    which node

nvm

  1. 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
  2. Open a new Terminal window, then install the latest LTS and make it the default.
    nvm install --lts
    nvm alias default 'lts/*'
  3. Pin a version per project with a .nvmrc file and switch to it with nvm use.
    echo "24" > .nvmrc
    nvm use
    node -v

fnm

  1. Install fnm with Homebrew.
    brew install fnm
  2. 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
  3. 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

From the Node.js previous releases page
VersionCodenameStatus
v26None yetCurrent
v24KryptonLTS
v22JodLTS
v20IronEnd 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 24

fnm

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

  1. Choose a method in the picker. The steps for that method appear with copy buttons.
  2. Run the commands in Terminal, one block at a time.
  3. Run the verify commands to confirm node and npm both answer with a version number.
  4. If something fails, paste the error into the error fixer to see the likely cause and the fix.

Tips

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.

Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.

More in Guides

We.Inc is an AI-powered website builder you can resell under your own brand. Launch a branded client dashboard, bill on Stripe Connect, and deliver AI-generated websites in minutes. White-label plans start at $99 a month for 25 client sites, with a 7-day free trial and no per-site fees.

Product

Who It's For

Features

Resources

Company

View Sitemap