Node.js has risen to be among the top JavaScript runtime environments to develop scalable web applications. It doesn't matter if you’re developing an API, microservices or real-time applications Node.js has the speed, flexibility and developer-first ecosystem that you want.
If you're using macOS, we're assuming you've had your fair share of woes when you did not properly install Node.js and had to deal with the frustrations of getting it to work properly.
In this blog we'll cover the best and most stable ways to install Node.js on macOS and weigh in on all the pros and cons, so you can arrive at an install that works for your own workflow.
Why Use Node.js on macOS?
macOS has a Unix-based environment that is very similar to Linux, so it is very appealing to developers. Here are the reasons why Node.js works great on macOS:
A Great Terminal for Developers: macOS comes with a great terminal for package management and automation.
Integration: It works well with 'npm', 'Git', 'VS Code', and other development tools.
Flexibility: You can build, test, and deploy apps, across platforms.
ARM: The new Apple Silicon (M1, M2, M3) are ARM-based and have optimized builds of 'Node.js' to run faster.
Prerequisites Before Installation
Before you begin installing Node.js, follow these quick checks:
1. Check existing installations:
node -v
npm -v
If you see version numbers, Node.js is already installed.
2. Verify your macOS architecture:
uname -m
Output will show either x86_64
(Intel) or arm64
(Apple Silicon).
3. Ensure Homebrew is available (optional):
brew -v
If not installed, you can install it during the process.
4. Decide your goal:
- Need a single stable version → use
.pkg
or Homebrew. - Need multiple versions → use
nvm
orn
.
Different Methods to Install Node.js on macOS
Method 1: Install Node.js via the Official macOS Installer
The official Node.js macOS installer is the easiest and most beginner-friendly option.
Steps:
- Visit the official Node.js download page.
- Download the latest macOS Installer (.pkg) file (choose LTS or Current).
- Run the installer and follow the on-screen prompts.
- Verify installation:
node -v
npm -v
Method 2: Install Node.js Using Homebrew
Homebrew is a popular macOS package manager that simplifies software installation.
Steps:
- Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Node.js:
brew install node
- Verify:
node -v
npm -v
- To update Node.js in the future:
brew update
brew upgrade node
Method 3: Install Node.js via NVM (Node Version Manager)
If you work with multiple Node.js versions, NVM is the best option. It allows you to install, manage, and switch between versions easily.
Steps:
- Install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
- Add NVM to your shell configuration file:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
- Reload terminal:
source ~/.zshrc
- Install Node.js:
nvm install --lts
nvm use --lts
nvm alias default lts
- List installed versions:
nvm ls
Method 4: Install Node.js Using n
n
is a lightweight Node version manager installed via npm itself. It’s simpler than NVM but offers fewer features.
Steps:
- If Node.js is already installed:
npm install -g n
- Install or switch Node.js versions:
n lts
n latest
n 20.11.1
- Clean up old versions:
n prune
Troubleshooting Common Issues
Command Not Found: Node
If you are seeing this error, your shell path may not include the Node.js binary. Restart your terminal or add the correct path manually.
Multiple versions conflicting
You will need to uninstall previous installations or remove the conflicting path from your shell configuration.
npm permissions errors
Avoid sudo for npm installs, as much as possible. The better solution is to either use NVM or install packages locally to avoid this issue.
Apple silicon
If you're on an M1, M2, or M3 Mac, you should make sure the version of Node.js you are using is ARM compatible or that you installed it through NVM, which handles architecture differences for you.
Conclusion
Setting up Node.js on macOS is not difficult, but the way you do it depends on your needs. You can use the official .pkg
installer. Homebrew, or nvm (or other version managers) and they all have their own pros and cons We've researched this extensively and for people or developers managing multiple projects, nvm may provide the more desirable flexibility, while beginners might find the official .pkg installer the best method.
If you are not sure which one would suit your needs, or you need help configuring your Node.js environment, consider to hire node js programmers would ensure you are set up for maximum effectiveness leaving you to focus on developing/creating a great Node.js application. With the right installation method, you'll be well-suited to take advantage of Node.js in 2025 and beyond.
Top comments (0)