安装nvm成功后,将终端bash改成了zsh,然后在使用nvm安装node的时候总是提示找不到nvm命令.
在网上搜索了很多,但是并没有我这种情况,最后在nvm的Github文档中找到了答案(多读读官方文档是非常有用的!),
Note: If you’re using
zsh
you can easily installnvm
as a zsh plugin. Installzsh-nvm
and runnvm upgrade
to upgrade.
zsh不支持nvm命令,需要另行安装nvm扩展,也就是zsh-nvm
本人使用的是oh-my-zsh,其他的安装方法请看官方文档
首先下载zsh-nvm
在.oh-my-zsh/custom/plugins
中
zsh
1 | git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm |
然后在.zshrc
中添加
lisp
1 | plugins+=(zsh-nvm) |
然后重新打开终端,就发现nvm可以正常使用了.