• Modern UX

    Edit and navigate faster in the terminal with Warp's IDE-like input editor.

  • Warp AI

    AI suggests what commands to run and learns from your documentation.

  • Agent Mode

    Delegate tasks to AI and use natural language on the command line.

  • Warp Drive

    Save and share interactive notebooks, workflows, and environment variables.

  • All Features

How To Update NPM

Thumbnail for Razvan LudosanuRazvan Ludosanu

Razvan Ludosanu

Founder, learnbackend.dev

Published: 1/31/2024

About Terminus

The short answer

To upgrade npm to its latest version, you can use the following npm install command (effectively using npm to update npm):

 $ npm install -g npm

Run in Warp

Alternatively, to update npm to a specific version, you can use the following syntax instead:

 $ npm install -g npm@

Run in Warp

You can get the list of available npm versions on the official npmjs website.

Easily retrieve this command using Warp’s AI Command Search

If you’re using Warp as your terminal, you can easily retrieve this command using the Warp AI Command Search feature:

Thumbnail for

Entering update npm in the AI Command Search will prompt an npm command that can then quickly be inserted into your shell by doing CMD+ENTER.

Checking the current npm version

To check the current version of npm in use, you can use the -v flag (short for version) as follows:

 $ npm -v

Run in Warp

On the other hand, if you have multiple versions of npm installed and want to find out which npm binary is in use, you can run the following command:

 $ which npm

Run in Warp

Updating npm using nvm

If you are using nvm as your Node.js version manager, you can update npm to the latest version supported by your current Node.js distribution in use with the following nvm command:

 $ nvm install-latest-npm

Run in Warp

Updating npm for a specific Node.js version

If you have multiple versions of Node.js installed on your system, you can first list them:

 $ nvm ls

Run in Warp

Then switch to the desired Node.js version you want to use:

 $ nvm use 

Run in Warp

And finally update npm for this specific Node.js version:

 $ nvm install-latest-npm

Run in Warp

Updating npm manually

To download and install npm manually using the official npmjs install script, you can run the following curl command:

 $ curl -qL https://www.npmjs.com/install.sh | sh

Run in Warp

Note that the npmjs documentation strongly recommends you download and install npm using a tool like nvm; see https://docs.npmjs.com/downloading-and-installing-node-js-and-npm for more details.

Change to a specific npm version using npx to install a package

If your installed version of npm differs from the required npm version specified in the package.json file of your project:

 {"engines": {
    "npm": "7.24.2"
  }
}


Run in Warp

You can use the following npx command, which will execute the npm install command using the specified npm version, without actually updating the currently installed version of npm on your local machine.

To download and install npm manually using the official npmjs install script, you can run the following curl command:

 $ npx npm@  install [package …]

Run in Warp

For example:

 $ npx [email protected] install

Run in Warp

Written by

Thumbnail for Razvan LudosanuRazvan Ludosanu

Razvan Ludosanu

Founder, learnbackend.dev

Filed Under

Related Articles

Removing npm Packages

Learn how to remove packages locally, globally, and from the registry using the npm uninstall command.

Npm
Thumbnail for Utsav PoudelUtsav Poudel

Execute Packages With npx And npm

Discover the power of npm's npx tool, a developer's best friend for running packages without global installs.

Npm
Thumbnail for Glory KimGlory Kim

Install Dev Dependencies With npm

Learn how to install and update dev dependencies using the npm install command.

Npm
Thumbnail for Mansi ManhasMansi Manhas

Clear npm Cache

Learn how to clear the npm cache on Linux, macOS, and Windows.

NpmLinux
Thumbnail for Razvan LudosanuRazvan Ludosanu

Re-Installing Npm

Learn how to reinstall Node.js and npm on macOS, Linux, and Windows using `curl`, `brew`, `apt`, `nvm`, and Node installer.

Npm
Thumbnail for Razvan LudosanuRazvan Ludosanu

How To Reinstall Packages With Npm

Brief guide to reinstalling npm packages using npm

Npm
Thumbnail for Glory KimGlory Kim

Check Npm Package Version

Check an npm package version within your project

Npm
Thumbnail for Glory KimGlory Kim

Install NPM Packages From GitHub

Check an npm package version within your project

Npm
Thumbnail for Razvan LudosanuRazvan Ludosanu

List Installed Npm Packages

Learn how to list globally and locally installed packages with npm, including their dependencies.

Npm
Thumbnail for Razvan LudosanuRazvan Ludosanu

Trusted by hundreds of thousands of professional developers

Download Warp to get started

Download for Mac
Thumbnail for null