Nvm: node and nodejs shows different versions in ubuntu 16.04

Created on 30 Apr 2018  路  6Comments  路  Source: nvm-sh/nvm

  • Operating system and version:

  • nvm debug output:


nvm --version: v0.33.11
$SHELL: /bin/bash
$SHLVL: 1
$HOME: /home/rock
$NVM_DIR: '$HOME/.nvm'
$PATH: $NVM_DIR/versions/node/v8.11.1/bin:$HOME/bin:$HOME/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 4.13.0-39-generic #44~16.04.1-Ubuntu SMP Thu Apr 5 16:43:10 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux'
OS version: Ubuntu 16.04.4 LTS  
curl: /usr/bin/curl, curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
wget: /usr/bin/wget, GNU Wget 1.17.1 built on linux-gnu.
git: /usr/bin/git, git version 2.7.4
grep: /bin/grep (grep --color=auto), grep (GNU grep) 2.25
awk: not an option: --version
awk: /usr/bin/awk, 
sed: /bin/sed, sed (GNU sed) 4.2.2
cut: /usr/bin/cut, cut (GNU coreutils) 8.25
basename: /usr/bin/basename, basename (GNU coreutils) 8.25
rm: /bin/rm, rm (GNU coreutils) 8.25
mkdir: /bin/mkdir, mkdir (GNU coreutils) 8.25
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.7.0-git
nvm current: v8.11.1
which node: $NVM_DIR/versions/node/v8.11.1/bin/node
which iojs: 
which npm: $NVM_DIR/versions/node/v8.11.1/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v8.11.1
npm root -g: $NVM_DIR/versions/node/v8.11.1/lib/node_modules

nvm --version: v0.33.11
$SHELL: /bin/bash
$SHLVL: 1
$HOME: /home/rock
$NVM_DIR: '$HOME/.nvm'
$PATH: $NVM_DIR/versions/node/v8.11.1/bin:$HOME/bin:$HOME/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 4.13.0-39-generic #44~16.04.1-Ubuntu SMP Thu Apr 5 16:43:10 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux'
OS version: Ubuntu 16.04.4 LTS  
curl: /usr/bin/curl, curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
wget: /usr/bin/wget, GNU Wget 1.17.1 built on linux-gnu.
git: /usr/bin/git, git version 2.7.4
grep: /bin/grep (grep --color=auto), grep (GNU grep) 2.25
awk: not an option: --version
awk: /usr/bin/awk, 
sed: /bin/sed, sed (GNU sed) 4.2.2
cut: /usr/bin/cut, cut (GNU coreutils) 8.25
basename: /usr/bin/basename, basename (GNU coreutils) 8.25
rm: /bin/rm, rm (GNU coreutils) 8.25
mkdir: /bin/mkdir, mkdir (GNU coreutils) 8.25
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.7.0-git
nvm current: v8.11.1
which node: $NVM_DIR/versions/node/v8.11.1/bin/node
which iojs: 
which npm: $NVM_DIR/versions/node/v8.11.1/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v8.11.1
npm root -g: $NVM_DIR/versions/node/v8.11.1/lib/node_modules

  • nvm ls output:

->      v8.11.1
         system
default -> 8.11.1 (-> v8.11.1)
node -> stable (-> v8.11.1) (default)
stable -> 8.11 (-> v8.11.1) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.11.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.1 (-> N/A)
lts/carbon -> v8.11.1

  • How did you install nvm? (e.g. install script in readme, Homebrew): install script

  • What steps did you perform?
    sudo apt-get install nodejs
    sudo apt-get install npm
    sudo apt-get install nodejs-legacy

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

nvm install 8.11.1
nvm alias default 8.11.1
nvm use default

  • What happened?
    node -v
    v8.11.1

nodejs -v
v4.2.6

  • What did you expect to happen?

both versions should be same.

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?

  • If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?


needs followup

Most helpful comment

The issue here is because you installed node with apt - please remove the apt-installed node, and npm, and nodejs-legacy - none of those should ever be on any system.

After that, if you rerun the install script and restart your terminal, what happens?

All 6 comments

The issue here is because you installed node with apt - please remove the apt-installed node, and npm, and nodejs-legacy - none of those should ever be on any system.

After that, if you rerun the install script and restart your terminal, what happens?

Thanks for reply. Here's output. node -v v8.11.1
nodejs -v

The program 'nodejs' is currently not installed. You can install it by typing:
sudo apt install nodejs

@reckson node -v is right, the only thing that calls it nodejs is apt.

OK, so now that you only have an nvm-installed node, what does nvm current print out?

v8.11.1
So there is no need of nodejs apt?

Zero need, ever.

Looks like you're all set now :-)

Thank you so much =)

Was this page helpful?
0 / 5 - 0 ratings