使用tmux时不提供nvm [英] When using tmux nvm isn't being sourced
问题描述
我用brew在macOS上安装nvm,然后用nvm安装节点8.9.1,它运行良好,直到加载tmux,然后得到以下消息:
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.
经过一些故障排除后,我注意到当我使用tmux时,它使用的是另一个npm.
After some troubleshooting I noticed that when I use tmux it is using a different npm.
不使用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
使用tmux:
~ which npm
/usr/local/bin/npm
~ npm config get prefix
/usr/local
~ echo $NVM_DIR
/Users/mario/.nvm
按照brew中的安装说明,我在 .zshrc
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"
此外,如果我在tmux中手动获取/usr/local/opt/nvm/nvm.sh ,则它会按预期工作.
Additionally, if I manually source /usr/local/opt/nvm/nvm.sh within tmux it works as expected.
使用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.
版本:
- macOS 10.13.1
- zsh 5.4.2
- tmux 2.6
- nvm 0.33.6
- 节点8.9.1
- npm 5.5.1
推荐答案
除了nvm
之外,还安装了Node自酿软件包. nvm
正确地位于您的PATH
前面,以解析Node和npm的正确版本,因此您的工作结果是:
You have a Node homebrew package installed outside of and in addition to nvm
. nvm
is correctly prepending your PATH
to resolve the correct versions of Node and npm, hence your working result:
~ 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
但是,tmux导致对您的PATH
进行了修改,从而解决了不需要的非nvm版本. path_helper
是这里的罪魁祸首.
However, tmux is causing your PATH
to be modified such that the undesired, non-nvm versions are resolved. path_helper
is the likely culprit here.
您可以删除有问题的自制程序包,或者通过禁用或调整path_helper
的结果来确保正确的版本得到解决.
You can either remove the offending homebrew package or ensure the correct versions are resolved by disabling or tweaking the result of path_helper
.
前一种解决方案可能会打开另一罐蠕虫,因为您已经表明它是通过brewfile安装的,所以让我们看一下后者.
The former solution may open another can of worms as you've indicated it is installed via brewfile, so let's look at the latter.
一种可能的解决方案是在path_helper
运行之前手动取消设置PATH .另一个解决方案可能是修改/etc/paths
以删除/usr/local/bin
.
One potential solution is to manually unset your PATH before path_helper
runs. Another solution may be to modify /etc/paths
to remove /usr/local/bin
.
这篇关于使用tmux时不提供nvm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!