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?
On
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.
On
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
You can use
nvmthe Node version manager (https://github.com/creationix/nvm)