Nvm: npm is installing packages into the wrong nvm environment

Created on 10 Aug 2018  路  4Comments  路  Source: nvm-sh/nvm

  • Operating system and version: Arch Linux

  • nvm debug output:

nvm --version: v0.33.8
$SHELL: /bin/bash
$HOME: /home/solomon
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 4.4.23(1)-release (x86_64-unknown-linux-gnu)'
uname -a: 'Linux 4.17.11-arch1 #1 SMP PREEMPT Sun Jul 29 10:11:16 UTC 2018 x86_64 GNU/Linux'
OS version: Arch Linux  ()
curl: /usr/bin/curl, curl 7.61.0 (x86_64-pc-linux-gnu) libcurl/7.61.0 OpenSSL/1.1.0h zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.4) nghttp2/1.32.0
wget: not found
git: /usr/bin/git, git version 2.18.0
grep: /usr/bin/grep, grep (GNU grep) 3.1
awk: /usr/bin/awk, GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1, GNU MP 6.1.2)
sed: /usr/bin/sed, sed (GNU sed) 4.5
cut: /usr/bin/cut, cut (GNU coreutils) 8.29
basename: /usr/bin/basename, basename (GNU coreutils) 8.29
rm: /usr/bin/rm, rm (GNU coreutils) 8.29
sed: -e expression #1, char 9: Unmatched ) or \)
mkdir: , mkdir (GNU coreutils) 8.29
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.6.0
nvm current: v10.0.0
which node: $NVM_DIR/versions/node/v10.0.0/bin/node
which iojs: which: no iojs in ($NVM_DIR/versions/node/v10.0.0/bin:$HOME/google-cloud-sdk/bin:$HOME/.bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:~/.local/bin:~/.xmonad:~/.node_modules/bin:~/.local/bin:~/.xmonad)
which npm: $NVM_DIR/versions/node/v10.0.0/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v6.11.5
npm root -g: $NVM_DIR/versions/node/v6.11.5/lib/node_modules

  • nvm ls output:
        v6.11.5
         v8.9.3
         v8.9.4
        v8.11.1
        v9.11.1
->      v10.0.0
         system
default -> 8.11.1 (-> v8.11.1)
latest -> 10.0 (-> v10.0.0)
node -> stable (-> v10.0.0) (default)
stable -> 10.0 (-> v10.0.0) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.3 (-> N/A)
lts/carbon -> v8.11.3 (-> N/A)

  • How did you install nvm? (e.g. install script in readme, Homebrew):
    Install script in readme
  • What steps did you perform?
$ nvm use 10.0.0
$ which npm
/home/solomon/.nvm/versions/node/v10.0.0/bin/npm
$ npm install -g bower
npm WARN deprecated [email protected]: We don't recommend using Bower for new projects. Please consider Yarn and Webpack or Parcel. You can read how to migrate legacy project here: https://bower.io/blog/2017/how-to-migrate-away-from-bower/
/home/solomon/.nvm/versions/node/v6.11.5/bin/bower -> /home/solomon/.nvm/versions/node/v6.11.5/lib/node_modules/bower/bin/bower
+ [email protected]
added 1 package in 1.093s
  • What happened?

npm installed to the 6.11.5 environment.

  • What did you expect to happen?

I expected it to install packages into the 10.0.0 environment.

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

yes. Here is my $PATH:

$export $PATH
bash: export: `/home/solomon/.nvm/versions/node/v10.0.0/bin:/home/solomon/google-cloud-sdk/bin:/home/solomon/.bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:~/.local/bin:~/.xmonad:~/.node_modules/bin:~/.local/bin:~/.xmonad'

Most helpful comment

It very much is; delete it. You never want a custom prefix.

All 4 comments

Since npm config get prefix is returning a path that disagrees with nvm current, do you have a "prefix" line in ~/.npmrc? If not, what's printenv output?

Yes I do have a prefix line in .npmrc:

$ cat .npmrc 
prefix=/home/solomon/.nvm/versions/node/v6.11.5

That seems suspect. Should it be there?

It very much is; delete it. You never want a custom prefix.

Thanks this solved it!

Was this page helpful?
0 / 5 - 0 ratings