The fastest way to install npm on Mac
The easiest path is to install Node.js, which includes npm automatically. Download the installer from nodejs.org, open the .pkg file, and follow the on-screen prompts. When installation finishes, open Terminal and type node --version and npm --version to confirm both are working. This takes about five minutes and requires no command-line knowledge.
If you prefer not to download an installer, you can use Homebrew — a package manager for Mac that handles installation from the command line. If Homebrew is already on your Mac, type brew install node in Terminal and wait for it to finish. Both routes end with the same result: npm ready to use on your machine.
Key Takeaways
- The Node.js installer from nodejs.org is the simplest method and includes npm without extra steps.
- Homebrew is faster if you already have it installed, but requires typing one command in Terminal.
- After installation, verify both Node.js and npm work by running version commands in Terminal.
- npm is a package manager that downloads and manages code libraries your projects depend on.
- You only install npm once per Mac — after that, it updates itself when you update Node.js.
Installing npm using the Node.js installer
Visit nodejs.org in your web browser. The site shows two download buttons — one labeled LTS (Long Term Support) and one labeled Current. Choose LTS unless you have a specific reason to use the newest version. LTS receives security updates longer and works with more existing projects. Click the button and the installer downloads as a .pkg file.
Open your Downloads folder and double-click the .pkg file. A window appears asking where to install Node.js. Leave the default location unchanged and click Continue. The installer asks for your Mac password — this is normal, as it needs permission to write files to your system. Enter your password and click Install. When the process finishes, click Close.
Open Terminal (search for it in Spotlight by pressing Command+Space, typing "terminal", and pressing Enter). Type node --version and press Enter. The Terminal shows a version number like v18.17.0. Type npm --version and press Enter. You see another version number. Both commands working means npm is installed and ready to use.
Installing npm using Homebrew
This method is faster if Homebrew is already on your Mac, but slower if you need to install Homebrew first. Open Terminal and type brew --version. If a version number appears, Homebrew is installed and you can skip to the next paragraph. If Terminal says "command not found", Homebrew is not present — use the Node.js installer method instead.
With Homebrew installed, type brew install node in Terminal and press Enter. Homebrew downloads Node.js and npm, then installs both automatically. The process takes one to three minutes depending on your internet speed. When the Terminal prompt returns, type npm --version to confirm installation worked. You see a version number like 9.8.1.
What npm does and why you need it
npm stands for Node Package Manager. It downloads and installs code libraries — called packages — that your JavaScript projects depend on. When you start a new project, npm creates a file called package.json that lists every library your code uses. Instead of copying code manually, you type one command and npm fetches everything automatically.
npm also updates those libraries when new versions come out, keeps track of which versions your project needs, and prevents conflicts when different libraries require different versions of the same dependency. Without npm, managing JavaScript projects would require manually downloading and organizing hundreds of files. With npm, you manage everything through a single text file and a few commands.
Updating npm after installation
npm updates itself separately from Node.js. To check your current npm version, type npm --version in Terminal. To update npm to the latest version, type npm install -g npm@latest and press Enter. The -g flag means "global", which installs the update for your entire Mac rather than just one project.
On some Macs, this command requires sudo at the beginning: sudo npm install -g npm@latest. Terminal asks for your password. If you see a permissions error after running the command without sudo, try again with sudo added. After the update finishes, type npm --version again to confirm the new version is active.
Troubleshooting common installation problems
If Terminal says "command not found" after typing npm --version, the installation did not complete successfully. Restart your Mac and try the version command again — sometimes Terminal needs a restart to recognize newly installed programs. If the problem persists, uninstall Node.js completely and reinstall using the Node.js installer from nodejs.org.
If you see a permissions error when trying to install packages with npm, do not use sudo as a fix — this creates problems later. Instead, reconfigure npm's default directory by typing mkdir ~/.npm-global, then npm config set prefix '~/.npm-global', then export PATH=~/.npm-global/bin:$PATH. These commands tell npm to use a folder in your home directory instead of a system folder that requires special permissions.
If npm works but Node.js does not, or vice versa, one installation was corrupted. Uninstall both by dragging /usr/local/bin/node and /usr/local/bin/npm to the Trash if they exist, then reinstall Node.js using the installer. If you used Homebrew, type brew uninstall node instead, then brew install node to reinstall cleanly.
Choosing between the installer and Homebrew
Use the Node.js installer if this is your first time installing npm, if you are not familiar with Terminal, or if you do not have Homebrew. The installer is graphical, requires no typing, and works reliably on any Mac. It takes slightly longer but removes the possibility of command-line mistakes.
Use Homebrew if you already have it installed and use it regularly for other software. Homebrew is faster once it is set up, and it makes updating Node.js and npm simpler in the future — you type brew upgrade node instead of downloading a new installer. If you do not have Homebrew and do not plan to use it for other tools, the installer is the better choice.
Frequently Asked Questions
Do I need to install Node.js separately from npm?
No. npm comes bundled with Node.js, so installing Node.js automatically installs npm. You cannot install npm alone — they are distributed together. When you download from nodejs.org or use Homebrew, you get both in one installation.
Can I have multiple versions of npm on the same Mac?
You can have multiple versions of Node.js using tools like nvm (Node Version Manager), and each version of Node.js brings its own npm version. Most people use a single Node.js version and update it periodically. If you need multiple versions for different projects, research nvm after you have npm working with the standard installation.
What is the difference between npm and Node.js?
Node.js is a runtime that lets you run JavaScript outside a web browser. npm is a package manager that downloads libraries for your JavaScript projects. Node.js is the engine; npm is the tool that brings in the fuel. You need both, and they install together.
Do I need to reinstall npm when I update my Mac?
Usually not. npm and Node.js survive Mac updates if you installed them using the standard installer or Homebrew. If you encounter problems after a major Mac update, reinstalling Node.js using the same method you used originally fixes most issues.
Is it safe to use sudo with npm install commands?
Using sudo with npm is not recommended because it can create permission problems later. If you see a permissions error, reconfigure npm's directory as described in the troubleshooting section instead. This approach is safer and prevents issues when you try to install packages in the future.