Last Updated : 04 Sep, 2024
Summarize
Comments
Improve
Updating Node.js and NPM to the latest version ensures the newest features, performance improvements, and security updates. 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.
To update Node and NPM to latest versions we can use various methods like nvm (node version manager), node.js windows installer, npm and homebrew for macOS.
These methods are discussed below in detail.
Table of Content
- Using NVM
- Using Node.js Installer on Windows and macOS
- Using Homebrew on macOS
Check the Installed node version:
node -v
current installed version
Keeping your skills in Node.js and npm up-to-date is crucial for leveraging the latest features, security enhancements, and performance improvements in your development projects. This comprehensive course on Full-Stack Node.js will guide you through the essential techniques and practices for working with Node.js and npm, covering everything from basic concepts to advanced functionalities.
Using NVM
Step 1: Install NVM on your system, and verify nvm installation
nvm -v
Step 2: Use the following command to install and update Node to the latest version.
nvm install node
With the above command the compaitible NPM version will be automatically installed (e.g. npm v10 with node v22)
Step 3: After isntalling run this command to use the version mentioned in above response (v22 for now).
nvm use 22
Using NVM you can easily use any version of node if required
- 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>
Using Node.js Installer on Windows and macOS
Follow these steps to install Node.js on Windows using the Nodejs Installer.
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
Update npm using NPM
Step 4: use below npm command to upgrade npm to latest
npm install -g npm@latest
Step 5: Verify latest Installation update
npm -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
- How to install the previous version of node.js and npm?
- Difference between npm install and npm update in Node.js
- How to uninstall and update any dependencies through NPM?
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 .