How I can update nodejs and npm version?

Viewed 27311

I install nodejs and npm.

but now I want to update to the latest version, i tried many ways but it didn’t work.

3 Answers

For Node.js Upgrade:

Linux/Mac:

The module n makes version-management easy:

sudo npm install n -g

For the latest stable version:

sudo n stable

For the latest version:

sudo n latest

Windows:

Just reinstall node from the .msi in Windows from the node website.

For NPM Upgrade:

Kindly go through npm documentation for windows update.

For Linux/Mac:

You can upgrade to the latest version of npm using:

npm install -g npm@latest

Or upgrade to the most recent release:

npm install -g npm@next

managing node versions is easy with nvmfor linux or nvm for windows.

the docs for how to install them are available at their respective github repos.

  1. Try to install the nvm first.

Nvm is a script-based node version manager. You can install it easily with a curl and bash one-liner as described in the https://github.com/nvm-sh/nvm. It's also available on Homebrew.

  1. Assuming you have successfully installed nvm. The following will install the latest version of the node.
$ nvm install node --reinstall-packages-from=node
Related