Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can update nodejs and npm version?

Tags:

node.js

npm

I install nodejs and npm.

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

like image 507
Nitin Lawande Avatar asked Jan 09 '19 09:01

Nitin Lawande


People also ask

How can I update my NodeJS to the latest version?

To use this method for updates, follow the steps below: Run npm -v to see which installed version you're currently using. Run npm install npm@latest -g to install the most recent npm update. Run npm -v again to validate that the npm version was updated correctly.

How do I update npm to a specific version?

You can downgrade the npm version by specifying a version in the related commands. If you want to downgrade npm to a specific version, you can use the following command: npm install -g npm@[version. number] where the number can be like 4.9. 1 or 8 or v6.

Does npm get updated with Node?

If you have Node on your system, you have NPM, as well. With the npm command, you can check running Node. js versions and install the latest release. By adding the n module, you can interactively manage Node.


2 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
like image 161
kRiZ Avatar answered Nov 11 '22 01:11

kRiZ


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.

like image 22
Hussain Ali Akbar Avatar answered Nov 11 '22 01:11

Hussain Ali Akbar