-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NVM is not compatible with the npm config "prefix" option warning (OS X) #1245
Comments
(also per #855 (comment), you don't have any "prefix" in any I assume that Do you have anything in I'm seeing a few strange things here:
|
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! |
@peteringraham hm, it's possible that |
Looks like it worked. I guess this was a side-effect of
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 Thanks again for your help. |
It only shows up on one machine, where I have /home symlinked to a different mount point. nvm-sh/nvm#855 nvm-sh/nvm#1087 nvm-sh/nvm#1224 nvm-sh/nvm#1245 http://stackoverflow.com/questions/34718528/nvm-is-not-compatible-with-the-npm-config-prefix-option
It only shows up on one machine, where I have /home symlinked to a different mount point. nvm-sh/nvm#855 nvm-sh/nvm#1087 nvm-sh/nvm#1224 nvm-sh/nvm#1245 http://stackoverflow.com/questions/34718528/nvm-is-not-compatible-with-the-npm-config-prefix-option
It only shows up on one machine, where I have /home symlinked to a different mount point. nvm-sh/nvm#855 nvm-sh/nvm#1087 nvm-sh/nvm#1224 nvm-sh/nvm#1245 http://stackoverflow.com/questions/34718528/nvm-is-not-compatible-with-the-npm-config-prefix-option
@ljharb Thanks! |
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 |
@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 |
@ljharb why yes 😃 moving source nvm after all of that fixed my problem, thanks! PATH="/usr/local/bin:/usr/local/opt/subversion/libexec:/opt/apache-maven-3.3.9/bin:$PATH" |
Wow I'm tired of this issue - seems to affect me randomly on various machines and CI environments. 3 years old and still going strong. Not sure why it's marked as fixed? Nothing is fixed... none of the above solutions seem to work for me. |
@antony you can try the ways:
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
|
If you're using any other shell than bash, make sure to configure your tmux that way:
This solved it for me. |
MWumLi's fix worked for me. Yes, this was highly annoying and time-consuming to fix. I'm happy to report the fix is quite simple. |
When I use tmux, the bug apear, so I view code, find the real reason is PATH overlap which result in Determine if the nvm path exists error How to solve the bug?
nvm_change_path() {
local NVM_NPM_PREFIX
NVM_NPM_PREFIX="$(npm config --loglevel=warn get prefix)"
# if there’s no initial path, just return the supplementary path
if [ -z "${1-}" ]; then
nvm_echo "${3-}${2-}"
# if the initial path doesn’t contain an nvm path, prepend the supplementary
# path
elif ! (nvm_tree_contains_path "$NVM_DIR" "$NVM_NPM_PREFIX" >/dev/null 2>&1); then
nvm_echo "${3-}${2-}:${1-}"
# use sed to replace the existing nvm path with the supplementary path. This
# preserves the order of the path.
else
nvm_echo "${1-}" | command sed \
-e "s#${NVM_DIR}/[^/]*${2-}[^:]*#${3-}${2-}#g" \
-e "s#${NVM_DIR}/versions/[^/]*/[^/]*${2-}[^:]*#${3-}${2-}#g"
fi
}
|
It is not fixed! i'm having the same problem for multiple versions of node. tried uninstalling and reinstalling as suggested in some of the comments above. But that did not fix it for me. |
|
The Fix You can check this by doing the following:
If it points to something outside of $NVM_DIR it may be causing problems. The explanation First, I uninstalled node from brew brew uninstall node So I performed the following to ensure brew's node was gone:
No more errors YAY! In hindsight, I believe all I really needed to do was either rm the npm symlink in /usr/local/bin and perhaps the npm install source at /usr/local/lib/node_modules/bin/npm (not sure of this path). |
@MwumLi |
@rifler Do you install npm? Your result show npm not be installed. |
globally not, only via nvm |
@rifler Here, first say sorry, my code has little bug. |
I found that @bradydowling's fix worked for me. I recently installed yvm with brew and I guess it needed node as a dependency. Therefore I had a system node that couldn't handle the default prefix. Removing it with brew removed the error. |
I go this error because my EDIT: changing the home location in the macOS user settings is actually the better solution. |
@TitanNano's fix worked fo rme too. Mine was set to |
Exactly. |
This comment has been minimized.
This comment has been minimized.
I came against the same problem. |
I fixed it by seeing the prefix to the current version of node that I was using |
@dickwyn that's not a good fix; you shouldn't have a prefix set at all - doing that will break as soon as you're not using v12.16.2. |
@ljharb so, should I remove the prefix with |
@dickwyn you should ensure that |
I had something like |
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. |
Just run into this issue, and here's what I did to fix it:
|
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, |
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. |
I had the same issue as @radum - renaming my user folder to not include uppercase letters fixed it. |
@tflx i agree - but did the casing of |
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! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Good point @ljharb - the better fix was deleting the version entry in |
In my case I had:
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?
The text was updated successfully, but these errors were encountered: