简体   繁体   中英

How to install node.js

I did the following:

user@machine:~$ sudo n stable
   installed : v12.13.0 (with npm 6.12.0)
user@machine:~$ node --version
v8.10.0
user@machine:~$ which node
/usr/local/bin/node
user@machine:~$ /usr/local/bin/node --version
v12.13.0

I was expecting v12.13.0 to be installed, but node --version reveals v8.10.0.

What did I do wrong? How do I get v12.13.0 installed? FYI I am on Jetson Nano and I'm really just trying to get LTS Nodejs installed and don't know how.

BTW, if I do sudo apt-get install nodejs I only get v8.10.0.

MORE INFO:

user@machine:~$ node --version
v8.10.0
user@machine:~$ sudo node --version
v12.13.0

Seems sudo is affecting this somehow?

(I'm not very familiar with linux, but I'm learning... sorry if I'm missing "obvious" stuff.)

I worked around the problem by forgoing the use of n .

Here's how to install directly from the dist at nodejs.org.

wget https://nodejs.org/dist/v12.10.0/node-v12.13.0-linux-arm64.tar.gz
sudo tar -xf node-v12.13.0-linux-arm64.tar.gz --directory /usr/local --strip-components 1

It's very strange...

Could you try something?

mv /usr/local/bin/node /usr/local/bin/node.back
which node
mv /usr/local/bin/node.back /usr/local/bin/node

I just want to see what produce which if you remove the old node version binary.

Also provide more info about file /usr/local/bin/node , is it a symbolic link? If true, to what?

Can't comment but try replacing /usr/bin/node with a symbolic link to /usr/local/bin/node . Had similar issue some time ago that ate my brain. Solved it like this.

PS don't forget to backup

1) Try opening a new shell and checking what version of node you see there.

n installs the node binary by default to /usr/local/bin/node . You may already have had a node binary installed to /usr/bin/node , and your shell cache of known commands (paths) may be running the old one.

Example of problem with bash: https://github.com/tj/n/issues/588

2) If your OS has the command, you can run which -a node to see if you have multiple versions and where they are installed. (Uninstalling the ones you don't want reduces potential for confusion.)

3) Check the location of the intended version is in your PATH. If you are using n , try running n doctor . There are some extra checks that the version of node found is the one that is the one that n installed.

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