Description
Split off from #855 ; see that issue for a similar problem.
This is in OS X El Capitan, 10.11.6 . This error appears on starting a new shell:
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 v5.7.1 --silent` to unset it.
With the usual command in the .bashrc file:
export NVM_DIR="/Users/pingraham/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
Running either or both of the suggested fixes don't appear to do anything, though.
Note: I foolishly installed some node version globally while trying to fix this, and also foolishly upgraded npm once in an attempt to fix this, but ran into an entirely different npm bug ( npm/npm#13918 , if you're curious ) before giving up. On the other hand, NVM seems to sorta work anyway...? Maybe?
Here's some commands & their results:
node -v
v5.7.1
nvm use 5.7.1
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 v5.7.1` to unset it.
Running either or both of the suggested command doesn't change anything.
Oddly enough, the switch seems to work anyway... maybe...
nvm use 0.10
Now using node v0.10.33 (npm v1.4.28)
node -v
v0.10.33
nvm use 5.7.1
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 v5.7.1` to unset it.
node -v
v5.7.1
(I guess it happened regardless??)
Debugging info:
echo $PREFIX ; echo $NPM_CONFIG_PREFIX
(nothing, just empty lines)
nvm debug
nvm --version: v0.32.0
$SHELL: /bin/bash
$HOME: /Users/pingraham
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: system
which node: /usr/local/bin/node
which iojs:
which npm: /usr/local/bin/npm
npm config get prefix: /usr/local
npm root -g: /usr/local/lib/node_modules
(nvm debug, after switching)
nvm current: v0.10.33
which node: $NVM_DIR/v0.10.33/bin/node
which iojs:
which npm: $NVM_DIR/v0.10.33/bin/npm
npm config get prefix: $NVM_DIR/v0.10.33
npm root -g: $NVM_DIR/v0.10.33/lib/node_modules
nvm ls
v0.10.33
v5.7.1
-> system
default -> 5.7.1 (-> v5.7.1)
node -> stable (-> v5.7.1) (default)
stable -> 5.7 (-> v5.7.1) (default)
iojs -> N/A (default)
lts/* -> lts/argon (-> N/A)
lts/argon -> v4.5.0 (-> N/A)
No prefixes set in the environment, either:
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
It seems wrong to just ignore the error! Any ideas on what I could change? And is it a "Real" error, or just noise, since it seems that at least node -v acknowledges the switches anyway?
Activity
ljharb commentedon Sep 26, 2016
(also per #855 (comment), you don't have any "prefix" in any
.npmrc
files, and per #855 (comment), you don't have any case-insensitive form of "prefix" inenv
)I assume that
nvm ls
, after thenvm use
, has the->
pointing at "v5.7.1"?Do you have anything in
~/.bash_profile
and/or~/.bashrc
that refers toPATH
,nvm
, ornpm
?I'm seeing a few strange things here:
nvm use
complains about the prefix, but you don't have any prefix overrides set anywherenvm use
complains about the prefix, the node version still changes (it should be runningnvm deactivate
after printing that error)peteringraham commentedon Sep 26, 2016
I don't believe so, as far as PATH /nvm / npm references of note. My ~/.bash_profile:
The source of the bashrc seems like it shouldn't really be necessary to me, but .bashrc doesn't run if I don't include it.
The only thing in .bashrc of potential interest is pretty bog-standard:
For nvm ls: Not that one version. If I use 5.7.1, it points to "system" instead (which is hopefully harmless, since node -v indicates system IS 5.7.1 ). npm -v says it is 3.6.0. If I use some other version (e.g. v.0.10.36), then it points to that, yes (and npm -v gives 2.20 ).
Thanks for looking into this!
ljharb commentedon Sep 26, 2016
@peteringraham hm, it's possible that
v5.7.1
is corrupted? could you trynvm uninstall v5.7.1 && nvm install v5.7.1
and see if the issue is fixed?peteringraham commentedon Sep 27, 2016
Looks like it worked. I guess this was a side-effect of
sudo npm install -g
when trying to fix unrelated errors earlier.After running those, uninstalling, and reinstalling, no error message, node -v returns 5.7.1.
I'll re-open if something surprising happens later, but I think this is mostly fixed.
Note that
nvm ls
now claims it's using "5.7.1" rather than "system", so maybe using the system version of node isn't really supported? OTOH, this might be too specific & weird a situation to bother having specific commentary on.Thanks again for your help.
Work around long-standing annoying nvm bug
Work around long-standing annoying nvm bug
Work around long-standing annoying nvm bug
elimcjah commentedon Aug 31, 2017
@ljharb Thanks!
nvm uninstall v5.7.1 && nvm install v5.7.1
worked for me.jedwards1211 commentedon Dec 12, 2017
None of the fixes here seem to have worked for me, and I get this error regardless of which version I'm trying to switch to.
However, if I merely run
nvm use
a second time, it succeeds. I wonder if that's why some of these fixes "worked" for other folks here? If I open a new terminal I get the error again the first time I runnvm use
, and after that it's okay.68 remaining items