How to update npm ? - GeeksforGeeks (2024)

NPM (Node Package Manager) is the default package manager for Node.js and is written entirely in JavaScript. It manages all the packages and modules for Node.js and consists of command-line client npm.

It gets installed into the system with the installation of Node.js. The required packages and modules in the Node project are installed using npm.

A basic method to update npm on any device is by command- “npm update [-g] [<pkg>…]”.

Updating npm means the update node package manager to the latest version. The update of npm updates the Node.js and modules to the latest version.

How to Update npm on Windows, MacOS, or Linux

To update npm on Windows, MacOS or Linux follow the following methods. Depending on your operating system we have provided 5 methods to update npm on your machine.

  • Using npm update
  • Using npm@latest
  • Using PPA repository (only for Linux)
  • Using npm@next

Method 1: Using npm update

Write the following command to update the node package manager on your device(Windows, MacOS, or Linux)

npm update -g

How to update npm ? - GeeksforGeeks (1)

This method updates all globally installed packages to their latest versions.

Method 2: Using npm@latest

Write the following command to update the node package manager(NPM) to the latest version.

npm install npm@latest -g

How to update npm ? - GeeksforGeeks (2)

This command installs the latest version of NPM globally on your system(Windows, MacOS, or Linux).

Method 3: Using PPA repository (only for Linux)

Write the following command to install Node.js and npm.

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm

How to update npm ? - GeeksforGeeks (3)

Method 4: Using cache cleaning & stable installation (only for Linux)

Write the following command to update Node.js to a stable module.

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

How to update npm ? - GeeksforGeeks (4)

Method 5: Using npm@next

Write the following command to install the pre-release version of the Node package manager(npm)

npm install -g npm@next

How to update npm ? - GeeksforGeeks (5)

This command will install the next(pre-release) version of npm globally on your device.

Wrapping Up

npm allows developers to install, manage, and publish code libraries and modules written in JavaScript(JS). It is a very important component in Node.js as it is a large repository of open-source packages.

In this tutorial, we have covered 5 methods with examples to update npm/install the latest npm version on your device. These methods will work on every device(Windows, Linux, or MacOS). Install the latest NPM version to get the latest collection of packages and improve your web development experience!

Frequently Asked Questions- How to Update npm

Does npm install the latest version?

Yes, by default ‘npm install’ command installs the latest version of npm.

How to update npm using the command?

To update npm, use the command ‘npm install -g npm@latest‘. This will install the latest version of npm on your device.

How do I install npm?

You can install npm by simply installing Node.js, which installs npm alongside.

How do I check my npm version?

To check your npm version, write the command ‘npm-v’.


Last Updated : 22 Feb, 2024

Like Article

Save Article

Share your thoughts in the comments

Please Login to comment...

How to update npm ? - GeeksforGeeks (2024)
Top Articles
Latest Posts
Article information

Author: Jerrold Considine

Last Updated:

Views: 5789

Rating: 4.8 / 5 (58 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Jerrold Considine

Birthday: 1993-11-03

Address: Suite 447 3463 Marybelle Circles, New Marlin, AL 20765

Phone: +5816749283868

Job: Sales Executive

Hobby: Air sports, Sand art, Electronics, LARPing, Baseball, Book restoration, Puzzles

Introduction: My name is Jerrold Considine, I am a combative, cheerful, encouraging, happy, enthusiastic, funny, kind person who loves writing and wants to share my knowledge and understanding with you.