CentOS 7.6 NVM under different versions of Node.js installation management

nvm full name is Nodejs Node Version Manager Version Manager, which allows us to facilitate the Node.js version of the switch. nvm official version only supports Linux and Mac. Windows users can use nvm-windows. For details, please click on the official explanation .

Installation NVM

Check the information obtained, using curl or wget to install nvm (Version can use the latest version of the official website):

Output examples are as follows:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

CentOS 7.6 NVM under different versions of Node.js installation management

or:

Note: the installation finished, reopen the terminal to restart the Terminal Session

Install Node.js

new

1, install the latest version of Node.js command:

CentOS 7.6 NVM under different versions of Node.js installation management

2. Review the installation effect, the command:

Output is as follows:

Now using node v12.11.1 (npm v6.11.3)

CentOS 7.6 NVM under different versions of Node.js installation management

Stable (LTS)

1, the installation LTS version, the command: nvm install --lts

CentOS 7.6 NVM under different versions of Node.js installation management

Output is as follows:

      v10.16.3
->    v12.11.1
default -> node (-> v12.11.1)
node -> stable (-> v12.11.1) (default)
stable -> 12.11 (-> v12.11.1) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/dubnium (-> v10.16.3)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.16.1 (-> N/A)
lts/dubnium -> v10.16.3

CentOS 7.6 NVM under different versions of Node.js installation management

Switch Version

Can already see from the above list of installation, we installed a new version, a stable version. Namely: v12.11.1 and v10.16.3, how do we switch to a different version of it?
1. Switch to v12.11.1, the command:

display:

Now using node v12.11.1 (npm v6.11.3)

2. Switch to v10.16.3, the command:

display:

Now using node v10.16.3 (npm v6.9.0)

CentOS 7.6 NVM under different versions of Node.js installation management

Here, we will use the basic nvm, and to use whatever version you can switch freely. But if you want to play a little more cool, we should learn some tips below.

Using aliases

You must also think of each input v10.16.3 good trouble. And a long time, not necessarily remember back to live 16.3 or 18.3 version.

1, set the alias LTS version, the command:

display

10 -> v10.16.3

2, the latest version of the set alias command:

display

12 -> v12.11.1

CentOS 7.6 NVM under different versions of Node.js installation management

Guess you like

Origin www.linuxidc.com/Linux/2019-10/160918.htm