nvm: NVM is not compatible with the npm config "prefix" option warning (Mac OS) + npm ERR! code ELIFECYCLE npm ERR! errno 11 npm ERR! Exit status 11

  • Operating system and version: MAC OS High Siera 10.13.4
  • nvm debug output:
nvm --version: v0.33.11
$TERM_PROGRAM: Apple_Terminal
$SHELL: /bin/bash
$SHLVL: 1
$HOME: /Users/scottbarrett
$NVM_DIR: '$HOME/.nvm'
$PATH: $NVM_DIR/versions/node/v9.8.0/bin:/usr/local/apache-maven-3.3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)'
uname -a: 'Darwin 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64'
OS version: Mac 10.13.4 17E199
curl: /usr/bin/curl, curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
wget: not found
git: /usr/local/bin/git, git version 2.8.1
grep: /usr/bin/grep, 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: /bin/rm, 
mkdir: illegal option -- -
usage: mkdir [-pv] [-m mode] directory ...
mkdir: /bin/mkdir, 
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: v9.8.0
which node: $NVM_DIR/versions/node/v9.8.0/bin/node
which iojs: 
which npm: $NVM_DIR/versions/node/v9.8.0/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v9.8.0
npm root -g: $NVM_DIR/versions/node/v9.8.0/lib/node_modules
  • nvm ls output:

        v6.11.1
->       v9.8.0
         system
node -> stable (-> v9.8.0) (default)
stable -> 9.8 (-> v9.8.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)

command -v nvm

added to bash profile:

export NVM_DIR=“$HOME/.nvm” [ -s “$NVM_DIR/nvm.sh” ] && . “$NVM_DIR/nvm.sh” # This loads nvm [ -s “$NVM_DIR/bash_completion” ] && . “$NVM_DIR/bash_completion” # This loads nvm bash_completion

  • What happened? I’d had some node/npm permissions issues due to a local node install in the root directory. Removed that and then got nvm to avoid the issues going forward. When trying to run some scripts in a project to restore a mongoDB schema which was working fine until this point i’m now getting the following error:
nvm is not compatible with the "npm_config_prefix" environment variable: currently set to "/Users/scottbarrett/.nvm/versions/node/v9.8.0"
Run `unset npm_config_prefix` to unset it.
npm ERR! code ELIFECYCLE
npm ERR! errno 11
npm ERR! Exit status 11

running unset npm_config_prefix has no impact, have also removed the prefix from the ~/.npmrc file in case a preset issue existed.

  • What did you expect to happen?

I expected the DB to restored as normal with no npm/nvm errors

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

Yes:

export PATH=/usr/local/apache-maven-3.3.9/bin:$PATH

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 60 (25 by maintainers)

Most upvoted comments

@ljharb

Thank you for replying so quickly.

Well, my tmux config has been unchanged for some time, and as far as I can tell there’s only this line that interacts with PATH somehow:

set-option -g default-command "reattach-to-user-namespace -l zsh"

I’m also using both zsh and oh-my-zsh, their configs have been untouched for some time as well.


I have found this issue: https://github.com/creationix/nvm/issues/1652

The workaround from the first post helps, I have added this line

PATH="/usr/local/bin:$(getconf PATH)"

just before the line where I source nvm:

source $HOME/.nvm/nvm.sh

But as I understand it it’s just a workaround and nvm used to work fine without it.

v0.35.2 has fixed it, thx

It should be, but nvm v0.33.11 is wildly out of date; upgrade to v0.35.2.

In my case I’m using a fresh install (no previous npm or node installation), and zsh, seems this line cause the problem: export NVM_DIR="$HOME/.nvm" I replaced $HOME with the full path and is solved.

What fixed this error for me, finally, after trying everything:

Uninstall npm. Uninstall the homebrew version of nvm, reinstall via curl.

Most important:

In /usr/local/bin, delete the node alias.

Now it’s finding the NVM default alias first, not whatever I installed via Xcode.

I’m having the same issue. It seems to be related to the fact that I recently updated nvm.

In iterm, I have this:

~ $ node --version
v10.9.0
~ $ nvm version
v10.9.0

But then I run tmux and see this message:

nvm is not compatible with the npm config “prefix” option: currently set to “/usr/local” Run npm config delete prefix or nvm use --delete-prefix v10.9.0 --silent to unset it.

In tmux, here’s what the following commands display:

~ $ node --version
v9.7.1
~ $ nvm --version
0.33.11
~ $ nvm version
system
~ $ nvm ls default
        v10.9.0

I’ve removed the prefix entirely from the npmrc file, this now tracks node versions correctly when switching between versions via nvm

npm ls -g --depth=0 returns:

/Users/scottbarrett/.nvm/versions/node/v10.7.0/lib └── npm@6.1.0

npm config get prefix returns:

/Users/scottbarrett/.nvm/versions/node/v10.7.0

Edit: scratch that, still have the issue when using nvm install

Using the following fixed this issue for me:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion```

@ignaciocaamanio $HOME incorrectly has a trailing slash in it - remove that (wherever it’s defined) and everything should work again.

Couldn’t resolve, had to give up and hopefully after a device wipe and reset it should be resolved.

That’s even stranger that the && makes a difference.

If you have a run-script with nvm version && nvm version what do you get?

Tried removing via the README uninstall option, reinstalled and still have the same issue 😦

I don’t think the script is the issue as there are other members on the team using nvm working on this particular module with the npm commands executing successfully and don’t experience the same issue i get, nor have they ever seen this type of error before 😕