How to Update Node.js Versions on MacOS
Keeping your Node.js version up to date is essential for security, performance, and access to the latest features. New releases often include bug fixes, optimizations, and improvements that can enhance your development workflow.
If you're using macOS, there are several ways to update Node.js. In this guide, we’ll walk through different methods, including Homebrew, Node Version Manager (nvm), and manual installation.
Looking for instructions for Linux? Click here. Need help with Windows? Click here.
By the end of this article, you’ll have the latest version of Node.js running smoothly on your system—without breaking your existing projects. Let’s get started! 🚀
Check Your Current Node.js Version
Before updating Node.js, it’s important to check which version you currently have installed. You can do this by running the following command in your terminal or command prompt:
node -v
This command will return the installed version, e.g., v18.16.0
.
Understanding Node.js Release Lines: LTS vs. Current
Node.js follows a predictable release schedule with two main tracks:
- LTS (Long-Term Support): Recommended for most users, especially for production environments. LTS versions receive security updates and bug fixes for an extended period. The LTS version at the moment is v22.
- Current: Includes the latest features and improvements but may introduce breaking changes. It's ideal for developers who want early access to new capabilities. The current version at the moment, and until April 2025, is v23.
To determine whether your installed version is still actively maintained, visit the Node.js release schedule.
macOS users have multiple options for updating Node.js, but the most efficient methods are using Node Version Manager (nvm) or Homebrew. Other options include
n
or downloading the official installer from Node.js.
Method 1: Updating Node.js Using Homebrew
Homebrew is a popular package manager for macOS that allows you to easily install and update software. Though it doesn’t allow switching between multiple versions easily.
Steps to Update Node.js with Homebrew
- Update Homebrew to ensure you have the latest package definitions:
brew update
- If Node.js is not installed, run:
brew install node
- If you already have Node.js and want to upgrade:
brew upgrade node
- Verify the update:
node -v
If you installed Node.js via Homebrew, this method is the simplest and most recommended approach.
Method 2: Updating Node.js Using NVM (Node Version Manager)
NVM is an excellent tool for managing multiple Node.js versions, allowing you to switch between them as needed.
Installing NVM (If Not Installed)
First, check if nvm
is installed:
command -v nvm
If it's not installed, install it using:
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
source ~/.bashrc # or ~/.zshrc
Reload your shell:
source ~/.zshrc # For Zsh users
source ~/.bashrc # For Bash users
Verify that nvm
is installed:
command -v nvm
Updating Node.js with NVM
Once nvm
is installed, update Node.js as follows:
- Install the latest version:
nvm install node
- Install the latest LTS version:
nvm install node —lts
- Switch between versions:
nvm use <version>
- List installed versions:
nvm list
- Set a default version:
nvm alias default <version>
- Verify the update:
node -v
This method is ideal for developers working on multiple projects that require different Node.js versions.
**Using n
(Alternative to nvm
)
n
is another tool for managing Node.js versions, though it requires global npm installation.
- Install n
npm install -g n
- Install the Latest Node.js Version
sudo n latest
- Install the latest LTS version:
sudo n lts
Method 3: Updating Node.js by Manually Downloading
For users who prefer a graphical interface, you can download the latest Node.js version from the official Node.js website.
- Visit the website and download the macOS Installer (.pkg).
- Run the installer and follow the on-screen instructions.
Verify the installation: \
node -v`
npm -v
Final Verification
After updating, confirm that Node.js is running the latest version:
node -v
npm -v
For developers and organizations seeking enhanced security, performance monitoring, and reliability, N|Solid is the best solution. N|Solid is an enterprise-grade platform built on Node.js, offering real-time insights, vulnerability scanning, and advanced diagnostics to ensure your applications run securely and efficiently. With features like built-in CVE monitoring and proactive alerts, N|Solid helps teams stay ahead of security risks, even as the Node.js ecosystem evolves. It’s an invaluable tool for teams navigating the challenges of upgrading and maintaining Node.js applications.