Nvm: Globally installed cli packages not available after NPM install

Created on 28 Nov 2018  路  7Comments  路  Source: nvm-sh/nvm

  • Operating system and version:
    OSX Mojave 10.14.1
    NVM v. 0.33.11

  • nvm debug output:


nvm --version: v0.33.11
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$SHLVL: 1
$HOME: /Users/<user>
$NVM_DIR: '$HOME/.nvm'
$PATH: $HOME/.gem/ruby/2.5.1/bin:$HOME/.rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/bin:$HOME/.rubies/ruby-2.5.1/bin:$HOME/miniconda3/bin:$HOME/bin:/usr/local/bin:/usr/local/sbin:$NVM_DIR/versions/node/v10.12.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:$HOME/.rvm/bin:$NVM_DIR/versions/lib/node_modules
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.3 (x86_64-apple-darwin18.0)'
uname -a: 'Darwin 18.2.0 Darwin Kernel Version 18.2.0: Fri Oct 5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64'
OS version: Mac 10.14.1 18B75
curl: /usr/bin/curl, curl 7.54.0 (x86_64-apple-darwin18.0) libcurl/7.54.0 LibreSSL/2.6.4 zlib/1.2.11 nghttp2/1.24.1
wget: not found
git: /usr/local/bin/git
/usr/bin/git, git version 2.18.0
grep: grep: aliased to nocorrect grep --color=auto (nocorrect grep --color=auto), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20070501
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
sed: /usr/bin/sed,
cut: illegal option -- -
usage: cut -b list [-n] [file ...]
       cut -c list [file ...]
       cut -f list [-s] [-d delim] [file ...]
cut: /usr/bin/cut,
basename: illegal option -- -
usage: basename string [suffix]
       basename [-a] [-s suffix] string [...]
basename: /usr/bin/basename,
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file
rm: rm: aliased to rmi (rmi),
mkdir: illegal option -- -
usage: mkdir [-pv] [-m mode] directory ...
mkdir: mkdir: aliased to nocorrect mkdir -p (nocorrect mkdir -p),
xargs: illegal option -- -
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
             [-L number] [-n number [-x]] [-P maxprocs] [-s size]
             [utility [argument ...]]
xargs: /usr/bin/xargs,
nvm current: v10.12.0
which node: $NVM_DIR/versions/node/v10.12.0/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v10.12.0/bin/npm
npm config get prefix: $NVM_DIR/versions
npm root -g: $NVM_DIR/versions/lib/node_modules

  • nvm ls output:

       v10.11.0
->     v10.12.0
        v11.1.0
default -> 10.12.0 (-> v10.12.0)
node -> stable (-> v11.1.0) (default)
stable -> 11.1 (-> v11.1.0) (default)
iojs -> N/A (default)
lts/* -> lts/dubnium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.4 (-> N/A)
lts/carbon -> v8.12.0 (-> N/A)
lts/dubnium -> v10.13.0 (-> N/A)

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

  • What steps did you perform?
    Attempted to use Expo CLI tools installed globally via NPM

  • What happened?
    Can't execute the expo command. No globally installed modules via NVM can be executed unless installed locally and prefixed with npx

  • What did you expect to happen?
    I should be able to run global cli tools (i.e. expo [command]) but I can't for the life of me figure out how to get my path to recognize the modules installed via NVM

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?
    Only adding to it, it doesn't mutate or remove any PATHs

This isn't the first time I've tried to install a global cli tool and get a 'command not found'. It's getting frustrating and I've looked all over the place for documentation about a solution or proper method for global installs.

I've tried manually adding the /.nvm/versions/lib/node_modules to my PATH. Nothing works.

How do I fix this?

Screenshot of attempt to install globally, source my zshrc & then run expo command (even quitting iTerm and reopening does nothing):
screen shot 2018-11-27 at 4 38 01 pm

Most helpful comment

save-prefix is fine, altho ^ (the default) is better - but prefix definitely needs to be deleted.

Now that it's removed, npm install -g should put expo in the right place, and everything should Just Work :-)

All 7 comments

The implication is that something is modifying your PATH somehow - if nvm current prints out a version, then npm root -g should be in your PATH, and npm install -g expo, eg, should then make which expo print out the path (inside npm root -g) to that binary.

ohhh i see the issue. .nvm/versions/bin isn't supposed to be a thing that exists - where did that path come from?

Do you have anything related to "prefix" in ~/.npmrc? It's almost like you tried to make global modules shared across nvm-managed node versions, which doesn't work for a multitude of reasons.

Just checked and I had two prefix-related options set (I don't remember setting them at all...)

save-prefix=~

prefix=/Users/benji_mbp/.nvm/versions

Deleted them. To be honest I don't remember how I ended up with a /versions/bin, i added those in the PATH 'cause the install log told me that's where it was stashing stuff.

Do you know what I can do to fix it?

save-prefix is fine, altho ^ (the default) is better - but prefix definitely needs to be deleted.

Now that it's removed, npm install -g should put expo in the right place, and everything should Just Work :-)

It works now! Thanks so much, I appreciate the prompt response. Cheers!

I had the above symptoms with expo-cli. Turns out I had it in my project dependancies 馃う Removing it from my project meant that the globally-installed version was used 馃憤 Hopefully this helps someone.

Was this page helpful?
0 / 5 - 0 ratings