简体   繁体   English

zsh:找不到命令:nvm

[英]zsh: command not found: nvm

Recently, I've been trying to use nvm to manage node version.最近一直在尝试使用nvm来管理node版本。 I successfully installed nvm on Mac OS Catalina(10.15.6) and I can switch between version from the terminal.我在 Mac OS Catalina(10.15.6) 上成功安装了 nvm,我可以从终端切换版本。

However, if I try to do the same thing with the integrated terminal on VSCode, I get zsh: command not found: nvm但是,如果我尝试在 VSCode 上使用集成终端执行相同的操作,我会得到zsh: command not found: nvm

Been looking for solutions or workaround, but there seems to be no relevant answers.一直在寻找解决方案或解决方法,但似乎没有相关答案。 Has anyone figure this out?有人弄清楚了吗?

Thanks in Advance提前致谢

When I installed VSCode, oh-my-zsh and NVM using homebrew I had the same issue.当我使用自制软件安装 VSCode、oh-my-zsh 和 NVM 时,我遇到了同样的问题。 It appears to put wrong paths in ~/.zshrc (might be the same for bash).它似乎在 ~/.zshrc 中放置了错误的路径(对于 bash 可能是相同的)。

Solution:解决方案:

  1. Open ~/.zshrc or ~/.bashrc打开 ~/.zshrc 或 ~/.bashrc
  2. Create a backup of that file in case something goes wrong创建该文件的备份以防出现问题
  3. Compare paths under the line比较行下的路径

export NVM_DIR="$HOME/.nvm"

  1. Now you need to fix the two paths if different than those below如果与下面的路径不同,现在您需要修复这两个路径

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

  1. Type source ~/.zshrc or source ~/.bashrc in terminal depending on what you use.根据您使用的内容,在终端中键入source ~/.zshrcsource ~/.bashrc
  2. Restart VSCode built-in terminal and see if that helped.重启 VSCode 内置终端,看看是否有帮助。 Good luck!祝你好运!

I figured this out so I'll post an answer.我想通了,所以我会发布一个答案。

  • BTW I'm a Mac user.顺便说一句,我是 Mac 用户。 Not really sure about windows.不太确定 windows。

The reason why I get the zsh: command not found error was because I had Visual Studio Code placed under the Documents directory.我收到zsh: command not found错误的原因是因为我将 Visual Studio Code 放在了 Documents 目录下。

It seems like VSCODE terminal works properly when it is set under the Applications folder .当 VSCODE 终端设置在Applications 文件夹下时,它似乎可以正常工作。

Make sure to place VSCode under Application folder.确保将 VSCode 放在应用程序文件夹下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM