How to Update Node.js and NPM to the Latest Version? - GeeksforGeeks (2024)

Improve

Node.js is popular among web developers for building a dynamic web application. It is used for server-side scripting. Node Package Manager (NPM) is the package manager for Node.js. It serves as a command-line utility to interact with the npm online repository for package installation, version management, and dependency management.

It is important to keep Node.js and NPM updated for better performance and to get new features. It is a good practice to update your software versions to the newest as older versions could lead to security vulnerabilities and privacy issues.

In this article, we learn to update Node version and NPM. The steps might be confusing a bit, but are promising to update your Node.js using NPM.

Update Node.js Using NVM

NVM was originally developed for Linux systems. however, NVM can be installed separately for Windows systems by the following steps:

  1. Go to this site: https://github.com/coreybutler/nvm-windows/releases
  2. Install and unzip the nvm-setup.zip file
  3. From cmd, type nvm -v to ensure nvm is installed.

After installing nvm, the following can be done to update Node version to the latest version:

nvm install <version>

How to Update Node.js and NPM to the Latest Version? - GeeksforGeeks (1)

Check the list of available Node.js version in the system using the following command:

nvm list 

To use the desired version, use the following command:

nvm use <version>

How to Update Node.js and NPM to the Latest Version? - GeeksforGeeks (2)

Update npm: To update NPM, use the following command:

npm install -g npm

Output:

How to Update Node.js and NPM to the Latest Version? - GeeksforGeeks (3)

Below is a demonstration for updating Node.js and npm versions for Linux systems. Install nvm in Linux:

# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash OR # wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

Check if nvm is installed successfully

Open a new terminal
nvm -v

To install latest version of node, use the following command.

# nvm install node
or
# nvm install --lts
or
# nvm install

How to Update Node.js and NPM to the Latest Version? - GeeksforGeeks (4)

How to Update Node.js and NPM to the Latest Version? - GeeksforGeeks (5)

Check all the available version of node on the system:

# nvm ls

How to Update Node.js and NPM to the Latest Version? - GeeksforGeeks (6)

Use a particular version

# nvm use 

How to Update Node.js and NPM to the Latest Version? - GeeksforGeeks (7)

Update npm to latest version:

# npm install -g npm 

How to Update Node.js and NPM to the Latest Version? - GeeksforGeeks (8)

Update Node.js without NVM

Node.js latest version can be download and install using theofficial website.It is simple and convenient manner. Follow the on-screen commands and update Node.js to its latest version.

Also Read

JavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples.



Last Updated : 09 Jan, 2024

Like Article

Save Article

Share your thoughts in the comments

Please Login to comment...

How to Update Node.js and NPM to the Latest Version? - GeeksforGeeks (2024)
Top Articles
Latest Posts
Article information

Author: Duane Harber

Last Updated:

Views: 6040

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Duane Harber

Birthday: 1999-10-17

Address: Apt. 404 9899 Magnolia Roads, Port Royceville, ID 78186

Phone: +186911129794335

Job: Human Hospitality Planner

Hobby: Listening to music, Orienteering, Knapping, Dance, Mountain biking, Fishing, Pottery

Introduction: My name is Duane Harber, I am a modern, clever, handsome, fair, agreeable, inexpensive, beautiful person who loves writing and wants to share my knowledge and understanding with you.