How to upgrade to the latest version nodejs

Recently found that when you install a nodejs tool with NPM, my version of some old nodejs. This is not a big problem, as long as the upgrade can, of course, is again from the latest version nodejs.org a way, but I think there should be an easier way, is to use n this toolkit, we can use NPM install n Kit, and then use it to upgrade nodejs, very convenient.

Method a: with n upgrade nodejs

 How to upgrade to the latest version nodejs

# Upgrade to the latest stable version

  installing : node-v10.16.1
      mkdir : /usr/local/n/versions/node/10.16.1
      fetch : https://nodejs.org/dist/v10.16.1/node-v10.16.1-linux-x64.tar.gz
  installed : v10.16.1

 How to upgrade to the latest version nodejs

# Upgrade to the latest version of the
$ n latest

# Upgrade to a customized version of
$ n v11.13.0

# Switch between version
$ n 11.13.0 (ENTER)

Delete developed version
$ n rm 11.13.0
with the development of versions of executed script
11.13.0 some.js $ n use

Method 2: NVM to upgrade nodejs

github download nvm

Configuration items into the environment variable

$ source ~/.bashrc

$ nvm --version

Customized version to upgrade to #

$ nvm install 11.13.0

# Upgrade to the latest version

$ nvm install lastest

# Upgraded to Stable

$ nvm install stable

Note: nvm when using the pit, it is recommended to use the n nodejs upgrade and version control.

Guess you like

Origin www.linuxidc.com/Linux/2019-08/159863.htm