Repository navigation
NVM is not compatible with the npm config "prefix" option warning (OS X) #1245
Description
Activity
(also per #855 (comment), you don't have any "prefix" in any
.npmrcfiles, 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_profileand/or~/.bashrcthat refers toPATH,nvm, ornpm?I'm seeing a few strange things here:
nvm usecomplains about the prefix, but you don't have any prefix overrides set anywhere- when
nvm usecomplains about the prefix, the node version still changes (it should be runningnvm deactivateafter printing that error)
Reacted by kxc-wraikny (wk)- addedbugsOh no, something's broken :-(Oh no, something's broken :-(needs followupWe need some info or action from whoever filed this issue/PR.We need some info or action from whoever filed this issue/PR.
on Sep 26, 2016 I don't believe so, as far as PATH /nvm / npm references of note. My ~/.bash_profile:
source ~/.bashrc if [ -f ~/.git-completion.bash ]; then . ~/.git-completion.bash fiThe 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:
export NVM_DIR="/Users/pingraham/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm eval "$(grunt --completion=bash)"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 ).
(after terminal start, or nvm use 5.7.1) nvm ls v0.10.33 v0.10.36 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)Thanks for looking into this!
@peteringraham hm, it's possible that
v5.7.1is corrupted? could you trynvm uninstall v5.7.1 && nvm install v5.7.1and see if the issue is fixed?Reacted by ralph, Elijah M., Eric Garcia, Laura Hofmann, Marco Bontempi, CivicTesla, risinek, @codedevil, Oswaldo Salazar, alkaliphile and 51 moreReacted by Bastian Wegge, Dmitry Vakarev, Morteza Ziyaeimehr, drc-JCromwell, Michael Schmerbeck, Luis Herranz, David Knight and Jules TReacted by CivicTesla, Andrew Ryan Carpenter, Eric Nagy and Gokul KulkarniReacted by Elijah M., Jénaïc Cambré, Eric Garcia, Marco Bontempi, CivicTesla, risinek, Oswaldo Salazar, Andrew Ryan Carpenter, Cameron Kalegi, Brian Ephraim and 14 moreReacted by risinek, Andrew Ryan Carpenter, viva-douner, Brian Sands, Andri Kurnia, Riccardo Persiani, Eric Nagy, Guilherme G. Bellotti, Artsiom Kharytonchyk, Kesha and 6 moreReacted by Jordan Moyo and Gokul KulkarniLooks like it worked. I guess this was a side-effect of
sudo npm install -gwhen trying to fix unrelated errors earlier.nvm uninstall 5.7.1 file is not writable: $NVM_DIR/versions/node/v5.7.1/bin/grunt Cannot uninstall, incorrect permissions on installation folder. This is usually caused by running `npm install -g` as root. Run the following commands as root to fix the permissions and then try again. chown -R pingraham "$NVM_DIR/versions/node/v5.7.1" chmod -R u+w "$NVM_DIR/versions/node/v5.7.1"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 lsnow 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.
Reacted by Jordan Harband, Elijah M., Carlos Castaño and Gerald- added 3 commits that reference this issue
on Feb 25, 2017 @ljharb Thanks!
nvm uninstall v5.7.1 && nvm install v5.7.1worked for me.Reacted by Jordan Harband, Bobby Siagian, Lucas Chapin, Hao Dong, Todd Metheny and jmprada88None 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 usea 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.Reacted by Kun Zhou, Maksad Donayorov, Ed Yoo, Gift, Rich Burdon, Jason Tiscione, Karl von Randow, Jonas Kello, Max Nanasy, Abdel and 1 more@jedwards1211 is there any chance you have something in your shell profile files that modifies the PATH after nvm is sourced? If so, a second
nvm usewould correct the PATH.Reacted by Lizzi Lindboe46 remaining items
nvm unalias defaultworked for me as well, thanks.I had this problem not when launching Ubuntu (in my WSL 1 env in Win10), but when opening tmux within it. Super annoying, those error messages should be removed since doing the fixes in them didn't help at all.
Reacted by Saurav Jaiswal, Alex O, Eli Zibin, Ajay Kumar, Andres Alcocer and Paweł WerdaJust run into this issue, and here's what I did to fix it:
- remove node:
brew uninstall node - install desired version:
nvm install 'lts/*' - set the default version:
nvm alias default 'lts/*' - delete npm prefix:
npm config delete prefix - set prefix to the node version used with nvm:
npm config set prefix $NVM_DIR/versions/node/v12.18.1
Reacted by B. Cedric Cogell, changwei and EJ- remove node:
Setting the prefix like that is both unnecessary and will prevent nvm from being able to switch versions.
@ljharb I had no issue switching from 12.x to 14.x 😉
@hrasoa if in node 14,
npm root -gpoints to node 12's npm, you will have issues. Global modules must not be shared across node versions.The route that got me to this error was mixing installations of node based packages using nvm and brew. This can get a bit painful as installing the heroku tools or yarn will install their own version of node. I was able to resolve my issues by only ever using nvm. Big YMMV.
Reacted by Jordan Harband, Subramanya Chakravarthi and John James JacobyI had the same issue as @radum - renaming my user folder to not include uppercase letters fixed it.
That really shouldn't be necessary IMO.@tflx i agree - but did the casing of
whoamiandecho $HOMEmatch? if not, fix that, as that's the issue.none of these work for my raspberry pi 3 running raspberry OS
@sbaraka then please file a new issue and file out the entire issue template. Thanks!
Good point @ljharb - the better fix was deleting the version entry in
${HOME}/.npmrc. No idea how it got there..Reacted by Jordan HarbandIn my case I had:
- nvm as oh-my-zsh plugin
- NVM_LAZY=1
- NVM_AUTOLOAD=1
I had to remove the NVM_LAZY variable from .zshrc and everything worked
If I want to run nvm in somewhere inside an npm script (or in the subprocess tree of one), then I do:
#!/bin/bash unset npm_config_prefix source $HOME/.nvm/nvm.sh . $HOME/.profile version=v14.15.3 nvm install $version nvm use $version # rest of script that uses node version $version
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:
With the usual command in the .bashrc file:
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:
Running either or both of the suggested command doesn't change anything.
Oddly enough, the switch seems to work anyway... maybe...
(I guess it happened regardless??)
Debugging info:
echo $PREFIX ; echo $NPM_CONFIG_PREFIX(nothing, just empty lines)
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?