Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installed on Ubuntu 16.04.2 LTS, and n <version> doesn't change which node version I am using. #451

Closed
trusktr opened this issue Jul 17, 2017 · 19 comments

Comments

@trusktr
Copy link

trusktr commented Jul 17, 2017

Issue Template:

Describe issue including what OS you are using

Ubuntu 16.04.2 LTS

Describe what version of N you have

2.1.7

Describe how you installed N

npm i -g n while on node v4.2.6 which is installed with default apt-get registry for my version of Ubuntu.

Steps to reproduce issue 1.2.3

npm i -g n
n latest
node -v

Describe the results you received

It outputs v4.2.6, but I was expecting v8.1.4

What version of npm you are using

5.0.3

Additional information you deem important (e.g. issue happens only occasionally):

> which n
/usr/local/bin/n
> node -v
v4.2.6
@trusktr
Copy link
Author

trusktr commented Jul 17, 2017

To work around the problem for now, I've symlinked /usr/local/bin/node to the version installed in /usr/local/n/. Another option is to manually update PATH.

@troy0820
Copy link
Collaborator

what is the output of which node? It seems the symlink didn't happen or the node you are using isn't the one from n. I have a docker container that is Ubuntu:16.04 you can try at troy0820/node-n:latest. I'm trying to reproduce your issue, but I'm not having any luck.

@stephenmcm
Copy link

stephenmcm commented Jul 19, 2017

I'm getting the same result.

>which node
/usr/local/bin/node
>ls -la /usr/local/bin/
lrwxrwxrwx  1 root root       27 Jul 19 13:52 n -> ../lib/node_modules/n/bin/n
-rwxr-xr-x  1 root root 29851602 Jul 19 13:52 node
lrwxrwxrwx  1 root root       38 Jul 19 13:52 npm -> ../lib/node_modules/npm/bin/npm-cli.js

Edit: Looks like it's an overuse of sudo that's tripping me up here.

@trusktr
Copy link
Author

trusktr commented Jul 19, 2017

~ ❯ which node
/usr/local/bin/node

Hmmm, maybe that's not the default one? I think sudo apt-get install nodejs installs /usr/bin/nodejs, but I'm not sure about /usr/local/bin/node.

@adamreisnz
Copy link

adamreisnz commented Aug 27, 2017

I seem to run into the same issue where n links the new version to /usr/local/bin/nodejs whereas my install has Node running from /usr/local/bin/node.

I've installed Node using the following:

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

For now fixing this using:

sudo n 8.4.0
sudo ln -sf /usr/local/n/versions/node/8.4.0/bin/node /usr/bin/node

Once linked, changing the version using n will automatically maintain the symlink correctly.

@adamreisnz
Copy link

May actually be a duplicate of #381
I've found that indeed after restarting the shell it did find the correct Node version.

@ivarni
Copy link

ivarni commented Sep 3, 2017

Restarting shell didn't work for me. It turned out that something (I'm guessing heroku toolbelt?) had added a new binary for me.

➜  ~ sudo n 6.7.0
➜  ~ node --version
v8.1.4
➜  ~ which -a node
/usr/local/heroku/bin/node
/usr/local/bin/node
/usr/bin/node
➜  ~ sudo ls -ltr /usr/local/heroku/bin 
total 33960
-rwxrwxr-x 1  500  500 34764936 Jul 11 03:10 node
-rw-r--r-- 1 root root      310 Jul 20 00:18 heroku.js
-rwxr-xr-x 1 root root      836 Jul 20 00:18 heroku
➜  ~ sudo rm /usr/local/heroku/bin/node 
➜  ~ node --version
v6.7.0

Removing that worked.

@sleekweasel
Copy link

I had something similar:

$ which -a node
/usr/local/bin/node
/usr/bin/node
$ /usr/local/bin/node -v
v8.4.0
$ which node
/usr/local/bin/node
$ /usr/bin/node -v
v5.4.1
$ node -v
v5.4.1
$ rehash
$ node -v
v8.4.0

So I needed to rehash (or quit and re-run the shell) to fix this.

This was from doing the git clone version of install and then the foregoing n-based installs, all in one shell. Hard to think how to fix this, except perhaps by making 'n' check whether 'which node' changes value and printing a ***** BIG OBVIOUS WARNING ***** about it for stupid people like me. :)

Here's hoping I won't suffer the npm install Buffer.alloc bug now.

@dandv
Copy link

dandv commented Feb 28, 2018

Same problem still, as of March 2018 (well, it's the same n version, 2.1.7). Restarting bash did fix it.

@guido4000
Copy link

It might help to remove the pre-installed version of node
sudo apt remove nodejs

@DMalagonH
Copy link

I solved it.
I uninstalled node with apt-get and then set 777 permisions to /usr/local/bin/node

sudo apt-get remove nodejs
sudo chmod 777 -R /usr/local/bin/node

Previously I had installed node 8.11.3 with:

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

and then I installed n with:

sudo npm -g install n
sudo n latest

But, when I changed the node version with n to 10.5.0 for example node -v showed 8.11.3. However, if I use sudo node -v it showed the correct version (10.5.0)

@janwirth
Copy link

@guido4000 thx - that fixed it.

@shadowspawn
Copy link
Collaborator

Restarting the shell was the most common fix.

This issue has not had any activity in over six months. It isn't likely to get acted on due to this report.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

Thank you for your contributions.

@shadowspawn
Copy link
Collaborator

n v6.1.2 has additional output for the situation when node command location changes, and the old location may be remembered by the current shell.

e.g.

Note: the node command changed location and the old location may be remembered in your current shell.
         old : /usr/bin/node
         new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"

(Longer transcript: #588 (comment))

@jokermt235
Copy link

After installing bu using root permissions i simply type >exit in terminal and relogin again as sudo
my node , and npm versions became a stable as I prefered before!

@alexisprog
Copy link

export PATH=$PATH:/usr/local/bin/node

@walebant
Copy link

export PATH=$PATH:/usr/local/bin/node

This solved it for me.

@alancrisanto

This comment has been minimized.

@shadowspawn

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests