简体   繁体   中英

Ubuntu 14.04: How to install specific version of nodeJS?

I used the following commands to install nodeJS version 8.x

1. sudo apt-get purge nodejs npm
2. curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
3. sudo apt-get install -y nodejs

When I run the command

node -v 

it shows v4.2.6 instead of the latest 8.x versions. Here is a screenshot.

NodeJS安装

Use nvm to handle multiple nodejs versions.

Installing nvm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

or

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

Installing node

nvm install <version>

Using desired version

nvm use <version>

First install Node.js via apt-get (eg v8):

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Once you have installed Node.js, use the npm package n to switch to any version:

Simply execute n <version> to install a version of node. If <version> has already been installed (via n ), n will activate that version.

Install n as global package and use n to install the latest version of Node.js:

npm i -g n
n latest

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM