简体   繁体   中英

Installing nvm on Ubuntu 14.04

I'm trying to install nvm on Ubuntu 14.04 but it doesn't seem to use the version I specify. I installed following the tutorial here https://github.com/creationix/nvm and I've also tried the one here https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps .

There are 2 node installations on my system already.

which node # => /usr/local/bin/node
node --version # => v0.11.13-pre
which nodejs # => /usr/bin/nodejs
nodejs --version # => v0.10.26

When I install nvm using the curl one liner they give you, and then use

nvm install 0.10.32

It creates an empty folder inside .nvm/v0.10.32 and .nvm/current symlinks to it. In addition the bin folder is also empty. This problem occurs if I install other versions of node. I suppose I could just clone a version of node into the folder its supposed to go in but idk if that's all I have to do. In addition, I'm not sure I know how to make my system use the nvm current (symlink from /usr/local/bin/node to .nvm/current ?) Without doing anything myself and only following the tutorial, node --version and nodejs --version never uses the version I specify with.

nvm use 0.10.32

Here is my personal guide how to install nvm (node version manager).

reference: https://github.com/creationix/nvm

1.) Install nvm (NOTE: There might be new versions in their website.)

curl https://raw.githubusercontent.com/creationix/nvm/v0.24.0/install.sh | bash

2.) Close the current terminal and use a new terminal then try nvm again.

3.) Install current node.js version by using:
nvm install node_version
ex: nvm install 0.10.32

4.) to check the nodejs version--> nvm list

5.) Setup a default node version in nvm so that everytime you restart the system it loads a default node version:

to get help: nvm -h
to get list of install node.js versions: nvm ls
to set a default alias: nvm alias default node_version

6.) Uninstall a specific node.js version:
nvm uninstall node_version

I understand that my answer may be outdated, but there was a very nice thesis in the ticket #809 , that using

$ npm install -g nvm

is wrong. To fix, you want to do

$ npm uninstall -g nvm
$ apt install curl
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
$ source ~/.bashrc
$ nvm install 5.1
$ nvm use 5.1

instead (given that curl hasn't yet been installed on that machine).

I just removed all of the offending node installations until my system used a version that was 0.10.* . It appears I tried to install node before or another program installed it.

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