nvm is not compatible with the npm config "prefix" option:
This error can occur when your NVM installation folder path has a Symbolic Link.
Explanation
The default installation path of NVM is: $HOME/.nvm
but your home folder could be a symbolic link for another drive, like my case.
Example, my home folder is a Symbolic Link to aother drive:
/home/myuser -> /bigdrive/myuser
This cause the prefix problem.
Solution
On your startup script (.bashrc or .zshrc or other), change the NVM folder to the direct path.
Ex: NVM_DIR="/bigdrive/myuser/.nvm"
.
.bashrc
export NVM_DIR="/bigdrive/myuser/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
This may be a conflict with your local installation of Node (if you had it installed via another way than NVM in the past). You should delete this instance of node:
- remove node_modules
sudo rm -rf /usr/local/lib/node_modules
- remove node
sudo rm /usr/local/bin/node
- remove node link
cd /usr/local/bin && ls -l | grep "../lib/node_modules/" | awk '{print $9}'| xargs rm
After you cant install nvm
Delete and Reset the prefix
$ npm config delete prefix
$ npm config set prefix $NVM_DIR/versions/node/v6.11.1
Note: Change the version number with the one indicated in the error message.
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 v6.11.1 --silent" to unset it.
Credits to @gabfiocchi on Github - "You need to overwrite nvm prefix"
I had the same problem and executing npm config delete prefix
did not help me.
But this did:
After installing nvm using brew, create ~/.nvm
directory:$ mkdir ~/.nvm
and add following lines into ~/.bash_profile
:
export NVM_DIR=~/.nvm
. $(brew --prefix nvm)/nvm.sh
(Check that you have no other nvm related command in any ~/.bashrc
or ~/.profile
or ~/.bash_profile
)
Open a new terminal and this time it should not print any warning message.
Check that nvm is working by executing nvm --version
command.
After that, install/reinstall NodeJS using nvm install node && nvm alias default node
.
More Info
I installed nvm
using homebrew
and after that I got this notification:
Please note that upstream has asked us to make explicit managing nvm via Homebrew is unsupported by them and you should check any problems against the standard nvm install method prior to reporting.
You should create NVM's working directory if it doesn't exist:
mkdir ~/.nvm
Add the following to
~/.bash_profile
or your desired shell configuration file:export NVM_DIR=~/.nvm . $(brew --prefix nvm)/nvm.sh
You can set
$NVM_DIR
to any location, but leaving it unchanged from/usr/local/Cellar/nvm/0.31.0
will destroy any nvm-installed Node installations upon upgrade/reinstall.
Ignoring it brought me to this error message:
nvm
is not compatible with thenpm config
"prefix" option: currently set to"/usr/local/Cellar/nvm/0.31.0/versions/node/v5.7.1"
Runnvm use --delete-prefix v5.7.1 --silent
to unset it.
I followed an earlier guide (from homebrew/nvm
) and after that I found that I needed to reinstall NodeJS. So I did:
nvm install node && nvm alias default node
and it was fixed.
Update: Using brew to install NVM causes slow startup of the Terminal. You can follow this instruction to resolve it.