I am trying to run another NodeJS version with nvm but getting this error:
$ nvm use v4.2.4
nvm is not compatible with the npm config \"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 ~/.nvmAdd the following to
~/.bash_profileor your desired shell configuration file:export NVM_DIR=~/.nvm . $(brew --prefix nvm)/nvm.shYou can set
$NVM_DIRto any location, but leaving it unchanged from/usr/local/Cellar/nvm/0.31.0will destroy any nvm-installed Node installations upon upgrade/reinstall.
Ignoring it brought me to this error message:
nvmis 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 --silentto 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.