fnm
fnm copied to clipboard
为什么我每次打开一个新的终端窗口,之前使用的node版本就失效?Why the last fnm use node version does not work when I open a new terminal window?
我使用 homebrew 安装的 fnm ,然后在 .zshrc 中末尾添加了eval "$(fnm env --use-on-cd)"
。但是每次打开新的终端窗口,之前设置的 node 版本就失效了,使用 node 的相关命令时提示 zsh: command not found: node
。
我使用的是MacMini 2023 M2Pro版本,系统版本是14.0。
I install the fnm by homebrew, and then add eval "$(fnm env --use-on-cd)"
in the last line of .zshrc file. But when I open a new window of Terminal every time, the node version I seted before is not working again, type in node command (like node --version
) will give me back zsh: command not found: node
.
What I use is MacMini 2023 M2Pro, OS version is 14.0.
fnm alias 18.0.0 default
?
fnm alias 18.0.0 default
?
不是这个原因。应该是使用homebrew安装后,环境变量配置的问题。我下载了fnm的项目,然后找到install.sh后执行安装。然后现在就一切正常了。应该是官网给出的配置环境变量的方法存在问题导致的。
官方给出的配置是在.zshrc文件中添加eval "$(fnm env --use-on-cd)"
,但是我添加后就出现了上述问题,指定node版本后新开终端窗口就不起作用了,即使指定default版本也一样。但是我下载使用instal.sh安装后,再打开.zshrc文件,看到添加的环境变量的配置代码为:
export PATH=/Users/equinoxflower/.fnm:$PATH
eval "`fnm env`"
这和使用homebrew安装后需要添加的环境变量完全不同。 当然,我对这其中的原理也不了解。所以也可能是我想错了。
thanks @EquinoxFlowerJG 's answer
if someone install with brew,add his anwser in .zshrc can resolve