Can't update nodejs with the sudo n stable tri

2019-09-13 09:26发布

I try the following :

Installing npm and nodejs through apt.

Installing the latest npm version, like :

npm npm@install -g 

Ending up with nodejs version 0.10 or something, and npm version 3.10.8

I try to install n throught npm, like (seems to be the answer on most forums) :

sudo npm cache clean -f 

sudo npm install -g n

Then, I try to install the crap :

sudo n stable 

Get an error :

cp: cannot stat '/usr/local/n/versions/node//bin': No such file or directory

etc etc

Any ideas ? All I want is to get the latest version of nodejs.

I have tried to download the node tar, but how can I get nodejs to become the same version as node ?

1条回答
forever°为你锁心
2楼-- · 2019-09-13 09:56

There is a good manager that will help you with all node versions. It's called nvm(Node version manager).

https://github.com/creationix/nvm

All install guides are on git page. I install it like this.

curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh -o install_nvm.sh

bash install_nvm.sh

Check to see if everything installed correctly

nvm --version

Then when you want update node you can just do

nvm install 6.9.1 (or any version you like)

nvm alias default 6.9.1

nvm use default

After restarting of your terminal run

node -v you should have 6.9.1 installed and used.

Hope this helps.

查看更多
登录 后发表回答