7

I install nodejs and npm.

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

xwlee
  • 1,053
  • 1
  • 10
  • 27
Nitin Lawande
  • 468
  • 1
  • 4
  • 8
  • 2
    Possible duplicate of [How do I update Node.js?](https://stackoverflow.com/questions/8191459/how-do-i-update-node-js) – TGrif Jan 09 '19 at 10:26

3 Answers3

24

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
kRiZ
  • 735
  • 7
  • 13
1

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.

Hussain Ali Akbar
  • 1,437
  • 1
  • 15
  • 26
1
  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
David Buck
  • 3,594
  • 33
  • 29
  • 34
Danna
  • 259
  • 2
  • 4