How to Update Node.js and NPM to the Latest Version?
Keeping Node.js and npm (Node Package Manager) updated is essential for ensuring you have the latest features, security updates, and performance improvements. This article will guide you through the steps to update Node.js and npm to the latest version on various operating systems, including Windows, macOS, and Linux.
This article delves into the steps for updating both Node.js and NPM. While the process might seem daunting initially, following these steps ensures a smooth and effective update using NPM.
Table of Content
- Using NVM
- Check if nvm is installed successfully
- Using Node.js Installer on Windows and macOS
- Using npm to Update npm
- Using Homebrew on macOS
Using NVM
After installing nvm, the following can be done to update the Node version to the latest version
nvm install <version>
Check the list of available Node.js versions in the system using the following command.
nvm list
To use the desired version, use the following command:
nvm use <version>
Update npm: To update NPM, use the following command
npm install -g npm
Output:
Check if nvm is installed successfully
Open a new terminal
nvm -v
To install the latest version of the node, use the following command.
# nvm install node
or
# nvm install --lts
or
# nvm install
Check all the available versions of the node on the system:
# nvm ls
Use a particular version
# nvm use
Update npm to latest version:
# npm install -g npm
Using Node.js Installer on Windows and macOS
Step 1: Download Installer by Visiting Node.js official website.
Step 2: Run Installer by Opening the downloaded installer. Follow the on-screen instructions to complete the installation.
Step 3: Verify Installation
node -v
Using npm to Update npm
Update npm
npm install -g npm@latest
Step 3: Verify latest Installation update
node -v
Using Homebrew on macOS
Step 1: Install Homebrew by Visiting brew.sh and follow the installation instructions.
Step 2: brew update
brew update
Step 3: Install Node.js
brew install node
Step 4: Update Node.js
brew upgrade node
Step 5: Verify latest Installation update
node -v
Also Read
JavaScript is best known for web page development but is also used in various non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples.
Contact Us