I used brew to install nvm on macOS, then I used nvm to install node 8.9.1 and it works fine, until I load tmux, then I get the following messages:
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 v8.9.1 --silent` to unset it.
After some troubleshooting I noticed that when I use tmux it is using a different npm.
Not using tmux:
~ which npm
/Users/mario/.nvm/versions/node/v8.9.1/bin/npm
~ npm config get prefix
/Users/mario/.nvm/versions/node/v8.9.1
~ echo $NVM_DIR
/Users/mario/.nvm
Using tmux:
~ which npm
/usr/local/bin/npm
~ npm config get prefix
/usr/local
~ echo $NVM_DIR
/Users/mario/.nvm
As per the installation note in brew, I added the following to my .zshrc
export NVM_DIR="$HOME/.nvm"
. "/usr/local/opt/nvm/nvm.sh"
Additionally, if I manually source /usr/local/opt/nvm/nvm.sh within tmux it works as expected.
Using tmux:
~ which npm
/usr/local/bin/npm
~ . /usr/local/opt/nvm/nvm.sh
~ which npm
/Users/mario/.nvm/versions/node/v8.9.1/bin/npm
~ npm config get prefix
/Users/mario/.nvm/versions/node/v8.9.1
Can anyone provide any insight into what could be causing this? I'm happy to provide additional info as necessary.
Versions:
- macOS 10.13.1
- zsh 5.4.2
- tmux 2.6
- nvm 0.33.6
- node 8.9.1
- npm 5.5.1