How to install npm on mac: A complete step-by-step guide
Learn how to install npm on macOS by installing Node.js via official installer, NVM, or Homebrew. This step-by-step guide covers prerequisites, methods, verification, troubleshooting, and best practices for a stable npm setup on your Mac.
Goal: Install npm on mac by getting Node.js, which ships npm by default. You can install Node.js using the official installer, or manage versions with NVM, or install via Homebrew. This quick guide outlines each method, prerequisites, and quick verification steps so you can get npm ready for your projects on macOS.
Understanding npm on macOS: Why you need Node.js
On macOS, npm (the Node package manager) is the gateway to JavaScript packages and tooling. npm itself is not a standalone language runtime; it is distributed with Node.js. That means to have npm, you must have Node.js installed. For most users, the simplest path to install npm mac is to install Node.js via an official package, which includes npm automatically. The Install Manual team notes that choosing the right installation method affects future maintenance, updates, and project consistency. This guide explains what npm does, how it integrates with Node.js, and what you should expect on macOS when you begin a new project.
According to Install Manual, starting with a clear plan helps avoid path and permission issues later, especially on systems with multiple user accounts or restricted runtime directories.
Prerequisites: macOS version, hardware, and permissions
Before you start, confirm that your Mac meets basic requirements: a supported macOS version, administrative access, and an active internet connection for downloads. npm relies on Node.js; having an updated macOS helps ensure compatibility with recent Node.js releases. If you’re new to command-line work, enable the Terminal app and adjust security settings to allow installation prompts. The Install Manual team emphasizes checking disk space and ensuring you can install software from the internet without corporate restrictions. Having Xcode command line tools installed can also reduce setup friction.
Methods to install npm on macOS
There are three common routes to get npm on a Mac: (a) the official Node.js installer, which bundles npm; (b) NVM (Node Version Manager) for multi-version workflows; and (c) Homebrew, a package manager that can install Node.js. Each method has trade-offs in simplicity, version control, and maintenance. As a rule of thumb, beginners often start with the official installer for a straightforward setup, then switch to NVM for multi-version needs. Install Manual research shows that aligning your method with project requirements reduces future friction and makes updates easier.
Official Node.js installer: how to use it to install npm on macOS
The simplest path to npm on mac is the official Node.js macOS installer. This package provides both node and npm in a single flow, with a standard installer wizard. After downloading the .pkg file, run it and follow the on-screen prompts. On success, open a new Terminal window and type node -v and npm -v to confirm versions. If you encounter permission prompts, grant access via System Preferences and re-run the installer. The official installer is typically the fastest route for first-time users and gives you a clean, system-wide Node.js setup.
Node Version Manager (NVM) for npm on macOS
NVM allows you to install and switch between Node.js versions without affecting system-level Node. Install NVM first (via curl or Wget), then install a Node.js version with nvm install --lts and set it as default with nvm use --lts && nvm alias default --lts. This method is ideal if you work on projects that require different Node.js versions. After setup, check node -v and npm -v to confirm the registry is healthy. NVM reduces risk when upgrading Node.js for newer projects and keeps existing projects stable.
Installing via Homebrew: a simple alternative
Homebrew can install Node.js and npm with a single command brew install node. This route keeps you aligned with macOS tooling and is convenient if you already use Homebrew for other software. After installation, restart your terminal, then verify with node -v and npm -v. If Homebrew prompts you to run brew doctor, follow the advice to fix any environment warnings. Homebrew is especially handy for ongoing maintenance and quick updates alongside other packages you manage with brew.
Verifying installation and troubleshooting
Verification is quick: open Terminal and run node -v and npm -v to confirm version numbers. If npm is missing, re-run the installer, or install Node via NVM or Homebrew depending on your chosen path. For permission-related errors, adjust directory ownership and avoid using sudo for npm install; instead, configure a local npm prefix. If you run into path issues, print PATH in the terminal and ensure /usr/local/bin or the NVM path are present.
Common issues and fixes
If your shell cannot find npm, ensure Node.js paths are in your PATH. On macOS, you may need to restart Terminal sessions or add export PATH="/usr/local/bin:$PATH" to your shell profile. If you encounter EACCES errors during global installs, switch to a local directory for global installs or switch to NVM to isolate permissions. Some users also encounter a missing node command after reboot; a fresh Terminal session or re-login often resolves it. Keeping a simple, repeatable setup script helps avoid drift across machines.
Best practices for keeping npm and Node.js healthy on mac
Keep Node.js and npm up to date with security patches and feature updates. Use a version manager like NVM when juggling multiple projects, and avoid installing global packages with sudo. Regularly audit your dependencies with npm audit and consider using npx for running one-off commands without global installs. Document your chosen approach in your project README so teammates follow the same setup.
590
Tools & Materials
- Mac computer with macOS(Ensure your system is up to date before starting.)
- Active internet connection(Needed for downloads and registry access.)
- Terminal app(Access to shell commands; macOS ships with Terminal.)
- Administrative access(Needed for system-wide installations.)
- Node.js installer (official macOS)(Use if you prefer the official installer path.)
- Homebrew (optional)(Useful if you already manage software with brew.)
- NVM (optional)(Choose if you need multiple Node.js versions.)
- Test project folder(Create a directory to run npm init -y.)
Steps
Estimated time: Total time: 20-45 minutes
- 1
Choose installation method
Decide whether you want the official Node.js installer, NVM, or Homebrew. This choice shapes the exact commands you’ll run and whether you’ll manage multiple Node.js versions in the future.
Tip: If you’re new, start with the official installer to avoid extra setup steps. - 2
Visit the Node.js official download page
Open your browser and go to the official Node.js website to locate the macOS installer, making sure you pick the latest LTS release for stability.
Tip: Verify you’re downloading the macOS Installer (.pkg) rather than the source tarball. - 3
Download the macOS installer
Click the macOS installer to download the .pkg file into your Downloads folder and confirm the download completes before proceeding.
Tip: Keep the downloaded file in a known location until installation finishes. - 4
Run the installer and follow prompts
Launch the .pkg file and complete the installation wizard, accepting default paths unless you have a specific need.
Tip: If asked for permission, allow the installer to make system changes. - 5
Open Terminal and verify versions
Launch a new Terminal window and run node -v and npm -v to confirm the installation was successful.
Tip: If you don’t see versions, restart Terminal or log out/log back in to refresh PATH. - 6
Decide on version management approach (NVM)
If you want multi-version support, install NVM before Node.js; otherwise skip to Step 9 for the official path.
Tip: NVM is useful for projects requiring different Node.js versions. - 7
Install Node.js with NVM
Install NVM, then run nvm install --lts and nvm use --lts to set the latest LTS version as default.
Tip: Set default with nvm alias default --lts for convenience. - 8
Or install Node.js with Homebrew
If you prefer Homebrew, run brew update && brew install node to install Node.js and npm via the package manager.
Tip: After install, restart your terminal to refresh PATH. - 9
Create a test project and initialize npm
Make a new directory for a test project and run npm init -y to generate a package.json and initialize npm usage in your project.
Tip: This confirms npm is functioning in your workspace. - 10
Update npm to the latest version
Run npm install -g npm to ensure you have the latest npm CLI features and fixes.
Tip: Global npm update helps with compatibility across projects. - 11
Configure a safe global install path
Set a user-level npm prefix so you avoid global permission issues.
Tip: Avoid using sudo for npm global installs. - 12
Document and save your setup
Record the method you used and any commands you ran so you can reproduce it later or onboard others.
Tip: Check in a README or your dotfiles for repeatability.
Got Questions?
Do I need Node.js to use npm on a Mac?
Yes. npm ships with Node.js, so installing Node.js is the straightforward way to get npm. You can choose the official installer, NVM, or Homebrew depending on your needs.
Yes. npm comes bundled with Node.js, so you’ll need Node.js installed to use npm on macOS.
Can I install npm without admin rights on macOS?
You can install without admin rights by using NVM or Homebrew for user-space Node.js, but some setup steps may require admin access, especially the initial system configuration.
Yes, using NVM or Homebrew can avoid needing admin rights for Node/npm, though some steps may still require admin access.
Which method is best for beginners?
For beginners, the official Node.js macOS installer is the easiest start because it bundles npm and uses a simple wizard. Later, you can switch to NVM for multi-version needs.
If you’re new, start with the official Node.js installer, then consider NVM for more control later.
How do I update npm after installation?
Run npm install -g npm to update the npm CLI to the latest version. This keeps the tool up to date without changing your Node.js installation.
Update npm by running npm install -g npm to get the latest features and fixes.
What if npm isn’t found after installation?
Check that Node.js is on your PATH and that you are using the correct Node version. If using NVM, ensure the desired version is active via nvm use.
If npm isn’t found, verify PATH and active Node version with nvm ls and npm -v.
Is it safer to avoid sudo with npm on mac?
Yes. Running npm with sudo can cause permissions issues. Prefer per-user installations or a version manager to handle permissions safely.
Avoid using sudo with npm on Mac; use a local prefix or a version manager.
Watch Video
Main Points
- Install Node.js to get npm on mac with the official method.
- Use NVM for flexible version control across projects.
- Verify installations with node -v and npm -v before starting work.
- Keep Node.js and npm up to date and maintain secure permissions.

