How to Upgrade Node.js on Different Operating Systems
Node.js, a popular JavaScript runtime, regularly releases updates to improve performance, fix bugs, and add new features. Staying up-to-date ensures compatibility with new libraries and keeps your system secure. Here’s a step-by-step guide on how to upgrade Node.js on Windows, macOS, and Linux.
1. Upgrade Node.js on Windows
Method 1: Using the Node.js Installer
Visit the official Node.js website.
Download the latest version for Windows (LTS or Current, depending on your needs).
Run the installer:
Follow the installation wizard.
It will automatically upgrade your existing Node.js version.
Method 2: Using nvm-windows
(Node Version Manager for Windows)
Download nvm-windows from the release page.
Install it and ensure it's added to your PATH.
Open a new Command Prompt or PowerShell window and run:
2. Upgrade Node.js on macOS
Method 1: Using Homebrew
Open Terminal.
Run the following commands:
brew update brew upgrade node
Verify the version:
node -v
Method 2: Using n
Install
n
(a version manager) globally if it’s not already installed:npm install -g n
Use
n
to install the latest version:n latest
Verify the version:
node -v
3. Upgrade Node.js on Linux
Method 1: Using NodeSource Repository (Debian/Ubuntu)
Open Terminal.
Add the NodeSource repository:
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
Install or upgrade Node.js:
sudo apt-get install -y nodejs
Verify the installation:
node -v
Method 2: Using n
(for all Linux distros)
Install
n
globally:npm install -g n
Use
n
to install the latest version:sudo n latest
Check the installed version:
node -v
Method 3: Using nvm
(Node Version Manager)
Install or update
nvm
by running:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
Restart your terminal or run:
source ~/.bashrc
Install the latest Node.js version:
nvm install node nvm use node
Verify:
node -v
Conclusion
Subscribe to my newsletter
Read articles from ByteScrum Technologies directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
ByteScrum Technologies
ByteScrum Technologies
Our company comprises seasoned professionals, each an expert in their field. Customer satisfaction is our top priority, exceeding clients' needs. We ensure competitive pricing and quality in web and mobile development without compromise.