Managing multiple versions of node with NVM

Source: Internet
Author: User

First, use the following command to install the NVM

$ curl-o-https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | Bash

When the download and installation is complete, the user exits the login or source the environment variable again.

$ . ~/.bashrc

View current system node version

$ NVM ls
            n/a
node-> stable (-> N/a) (default)
Iojs-> N/A (default)

You can see that no version of node is currently installed in the system

Install the specified version of node using "NVM Install"

$ NVM Install v6.10.0
Downloading and installing node v6.10.0 ...
Downloading https://nodejs.org/dist/v6.10.0/node-v6.10.0-linux-x64.tar.gz
... ######################################################################## 100.0%
Computing checksum with Sha256sum
checksums matched!
Now using node v6.10.0 (NPM v3.10.10)
Creating default Alias:default-> v6.10.0

$ nvm install v7.10.0
down Loading and installing node v7.10.0
... Downloading https://nodejs.org/dist/v7.10.0/node-v7.10.0-linux-x64.tar.gz
... ######################################################################## 100.0%
Computing checksum with Sha256sum
checksums matched!
Now using node v7.10.0 (NPM v4.2.0)

View node version information again

$ NVM List
        v6.10.0
->      v7.10.0
default-> v6.10.0
node-> stable (-> v7.10.0) (default) C5/>stable-> 7.10 (-> v7.10.0) (default)
Iojs-> N/A (default)
lts/*->-Lts/boron (->/n) lts
/argon-> v4.8.3 (-> N/a)
Lts/boron->-v6.10.3 (-> N/a)

There are now two versions of node, where "-> v7.10.0" describes the v7.10.0 version currently in use.

$ node-v
v7.10.0

$ nvm current
v7.10.0

You can now switch the node version using NVM use, such as:

$ NVM Use v6.10.0 now
using node v6.10.0 (NPM v3.10.10)

After switching, view the node version information "-> v6.10.0" to describe the v6.10.0 version currently in use.

$ NVM List
->      v6.10.0
        v7.10.0
default-> v6.10.0
node-> stable (-> v7.10.0) (default) C5/>stable-> 7.10 (-> v7.10.0) (default)
Iojs-> N/A (default)
lts/*->-Lts/boron (->/n) lts
/argon-> v4.8.3 (-> N/a)
Lts/boron->-v6.10.3 (-> N/a)
$ node-v
v6.10.0

$ nvm current
v6.10.0

Finally, if you want to set the default node version of the system user, you can use NVM alias default to set it.

$ NVM alias default v7.10.0
default-> v7.10.0

$ nvm ls
->      v6.10.0
        v7.10.0
Default  -> v7.10.0
Node-> stable (-> v7.10.0) (default)
stable-> 7.10 (-> v7.10.0) (default)
Iojs -> N/A (default)
lts/*-> Lts/boron (-> N/a)
Lts/argon-> v4.8.3 (-> N/a)
Lts/boron-> V 6.10.3 (-> N/a)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.