[patch] Update docs and add warning for 'nvm is not compatible with the npm config "prefix" option' edgecase error on Mac OS

Dimitris Karagiannis 2020-07-20 13:27:46 +03:00 committed by Jordan Harband
parent a5aec107df
commit a01deb11dc
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
2 changed files with 16 additions and 0 deletions

View File

@ -805,6 +805,16 @@ sudo chmod ugo-x /usr/libexec/path_helper
More on this issue in [dotphiles/dotzsh](https://github.com/dotphiles/dotzsh#mac-os-x). More on this issue in [dotphiles/dotzsh](https://github.com/dotphiles/dotzsh#mac-os-x).
**nvm is not compatible with the npm config "prefix" option**
Some solutions for this issue can be found [here](https://github.com/nvm-sh/nvm/issues/1245)
There is one more edge case causing this issue, and that's a **mismatch between the `$HOME` path and the user's home directory's actual name**.
You have to make sure that the user directory name in `$HOME` and the user directory name you'd see from running `ls /Users/` **are capitalized the same way** ([See this issue](https://github.com/nvm-sh/nvm/issues/2261)).
To change the user directory and/or account name follow the instructions [here](https://support.apple.com/en-us/HT201548)
[1]: https://github.com/nvm-sh/nvm.git [1]: https://github.com/nvm-sh/nvm.git
[2]: https://github.com/nvm-sh/nvm/blob/v0.35.3/install.sh [2]: https://github.com/nvm-sh/nvm/blob/v0.35.3/install.sh
[3]: https://travis-ci.org/nvm-sh/nvm [3]: https://travis-ci.org/nvm-sh/nvm

6
nvm.sh
View File

@ -2201,6 +2201,8 @@ nvm_die_on_prefix() {
fi fi
local NVM_NPM_PREFIX local NVM_NPM_PREFIX
local NVM_OS
NVM_OS="$(nvm_get_os)"
NVM_NPM_PREFIX="$(npm config --loglevel=warn get prefix)" NVM_NPM_PREFIX="$(npm config --loglevel=warn get prefix)"
if ! (nvm_tree_contains_path "${NVM_DIR}" "${NVM_NPM_PREFIX}" >/dev/null 2>&1); then if ! (nvm_tree_contains_path "${NVM_DIR}" "${NVM_NPM_PREFIX}" >/dev/null 2>&1); then
if [ "_${NVM_DELETE_PREFIX}" = "_1" ]; then if [ "_${NVM_DELETE_PREFIX}" = "_1" ]; then
@ -2213,6 +2215,10 @@ nvm_die_on_prefix() {
else else
nvm_err "Run \`${NVM_COMMAND}\` to unset it." nvm_err "Run \`${NVM_COMMAND}\` to unset it."
fi fi
if [ "${NVM_OS}" = 'darwin' ]; then
nvm_err "Make sure your username ($(whoami)) matches the one in your \$HOME path."
nvm_err "See the \"macOS Troubleshooting\" section in the docs for more information."
fi
return 10 return 10
fi fi
fi fi