Skip to content
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

Adding descriptions about symlinks in the 'nvm is not compatible with the npm config "prefix" option' error #1385

Open
MrOrz opened this issue Jan 17, 2017 · 8 comments
Labels
informational pull request wanted This is a great way to contribute! Help us out :-D

Comments

@MrOrz
Copy link

MrOrz commented Jan 17, 2017

I have ran into two machines that shows nvm is not compatible with the npm config "prefix" option error everytime ~/.nvm/nvm.sh is invoked, and which is also mentioned by existing issues.

In the end, I found that in both my machines, the home directories is symlinked to another location. By modifying the nvm load script .bashrc to set NVM_DIRto the path after symlink resolution, the error goes away for good. It works in new bash sessions as well.

That is, if in your machine it says something like

$ ls -l /home
lrwxrwxrwx 1 root root 9 May  7  2014 /home -> /srv/home
$ echo $HOME
/home/username

then your nvm will blow up with nvm is not compatible with the npm config "prefix" option. To correctly solve the issue, we should change NVM_DIR from $HOME/.nvm to something like /srv/home/username/.nvm.

I think the error message was useless in helping me figure this out. I spent some time tracing nvm.sh, inserting echo and disabling --silence to see my echo, to found that the system admin has setup those symlinks, and it is those symlinks that broke nvm.

Specifically, when the condition of this ifstatement turns true, it does not necessarily means that npm config get prefix is set by another npm instance. It just means that nvm is not sure if the prefix is set by nvm itself. I think extending the error message here to include the symlink issue can help others encountering this issue, since it is not uncommon to have home directories symlinked to somewhere else.

@MrOrz MrOrz changed the title Adding descriptions about symlinks and the 'nvm is not compatible with the npm config "prefix" option' error Adding descriptions about symlinks in the 'nvm is not compatible with the npm config "prefix" option' error Jan 17, 2017
@ljharb
Copy link
Member

ljharb commented Jan 17, 2017

The intention is for the string in nvm.sh to contain $HOME so that it auto-expands that path.

The true fix is related to #617 - it would need to change nvm to support traversing symlinks.

In the meantime, adding more information to the error message seems very helpful.

@qq756585379
Copy link

nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local/Cellar/nvm/0.33.0/versions/node/v5.11.0"
Run npm config delete prefix or nvm use --delete-prefix v5.11.0 to unset it.

how why?sorry,my english is poor

@ljharb
Copy link
Member

ljharb commented Jan 23, 2017

@qq756585379 Please file a separate issue; but nvm is not supported via homebrew. Please brew uninstall nvm and install it properly with the curl script in the readme.

@qq756585379
Copy link

qq756585379 commented Jan 31, 2017

i have installed via homebrew and also via curl , i find

vim .bash_profile
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
source .bash_profile

this may can do

@ljharb
Copy link
Member

ljharb commented Jan 31, 2017

@qq756585379 brew uninstall nvm, remove all nvm-related lines from your bash_profile/.bashrc, and then rerun the install script.

@qq756585379
Copy link

qq756585379 commented Feb 1, 2017

@ljharb yes,can you say 中文

@ljharb
Copy link
Member

ljharb commented Feb 1, 2017

Google translate gives me: brew uninstall nvm,从.bash_profile / .bashrc 中删除所有与nvm相关的行,然后重新运行安装脚本。

but that's the best i can do.

@qq756585379
Copy link

@ljharb thanks,你很棒

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
informational pull request wanted This is a great way to contribute! Help us out :-D
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants