1

I did sudo apt install nodejs and then checked my versions and I'm on version 8, which is a bit old.

I did sudo npm install -g n and then n latest and it says it has version 11 active, but then node --version spits out 8 again.

What gives?

Costa Michailidis
  • 7,691
  • 15
  • 72
  • 124

3 Answers3

1

You have to update you repository source for node by issuing this commands on your terminal:

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

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_11.x | bash -
apt-get install -y nodejs
harriebird
  • 69
  • 2
0

You can use nvm the Node version manager (https://github.com/creationix/nvm)

vizsatiz
  • 1,933
  • 1
  • 17
  • 36
0

n installs to /usr/local by default. Presumably apt installs to a different directory which is earlier in your PATH, so its version gets found first.

Removing the system installed node (as you did) since you are using n to manage node is simple, or edit your PATH to put /usr/local/bin before the other location.

Additional logging has been added to n in v6.0.0 to help recognise this setup issue, so hopefully will be less confusing in future.

If available, you can use which -a node to see all the locations that node is found in the PATH.

shadowspawn
  • 3,039
  • 22
  • 26