Upgrade Node.js to the latest version on Mac OS
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Upgrading Node.js on a Mac operating system is a straightforward process that ensures developers have access to the latest features, improved security, and better performance. This article provides a comprehensive guide to updating Node.js to its latest version on macOS, utilizing different methods and tools.
Understanding Node.js Versions
Node.js versions are released under two different channels:
- LTS (Long Term Support): These versions are intended for general use and are supported for an extended period. They are considered stable and are suitable for production environments.
- Current: These releases have the most recent features and improvements but are not as thoroughly tested as LTS versions. They are best for developers who want to experiment with the latest features.
Methods to Upgrade Node.js
Using Node Version Manager (nvm)
One of the most popular tools to manage multiple Node.js versions is Node Version Manager (nvm). It allows you to install, uninstall, switch between, and upgrade Node.js versions easily.
1. Install or Update nvm
If nvm is not installed on your system, you can install it with the following script:
Or, if you prefer using wget:
After installation, close and reopen your terminal, then verify the installation with:
2. Install the Latest Node.js Version
To install the latest Node.js version and use it immediately, you can run:
To upgrade Node.js to the latest LTS version, use:
Using Homebrew
Homebrew is a popular package manager for macOS that can also manage Node.js installations.
1. Install Homebrew
If not already installed, you can install Homebrew by running:
2. Install or Upgrade Node.js
To install Node.js for the first time, use:
To upgrade Node.js to the latest version available in Homebrew, run:
Verifying the Node.js Installation
After upgrading, you can verify the current version of Node.js and npm (Node Package Manager) with:
Common Issues and Troubleshooting
- Version not switching: Ensure that your terminal session is restarted after installing or upgrading Node.js versions.
- Global NPM packages missing: When switching Node.js versions using nvm, previously installed global npm packages may not be available. You can reinstall them or copy them from the older version.
| Feature | NVM Method | Homebrew Method |
| Version Management | Multiple versions can be managed and switched easily. | Manages only one active version at a time. |
| Flexibility | High – can install any version that Node.js provides. | Medium – Depends on the Homebrew repo updates. |
| Ease of Use | Requires initial setup and understanding of nvm commands. | Simple and integrated into the macOS ecosystem. |
Conclusion
Upgrading Node.js on macOS can be efficiently handled through nvm or Homebrew, depending on your specific requirements for version management and ease of use. Regular updating is crucial for accessing new features, performance improvements, and security patches.

