简体   繁体   English

命令“mongo”在 VSCode 终端中有效但在 iTerm2 zsh 终端中有效吗?

[英]Is there a reason the command 'mongo' works in VSCode terminal but not iTerm2 zsh terminal?

I just installed oh-my-zsh on iTerm2 and have been working on a project with MongoDB/node.我刚刚在 iTerm2 上安装了 oh-my-zsh,并且一直在使用 MongoDB/node 进行项目。

Now when I try to start the db with command 'mongo' I get a return 'zsh: command not found: mongo'现在,当我尝试使用命令 'mongo' 启动数据库时,我得到一个返回 'zsh: command not found: mongo'

the command works perfectly fine in the built-in terminal for VSCode.该命令在 VSCode 的内置终端中运行良好。

would like to be able to use iTerm exclusively instead of the vscode terminal.希望能够专门使用 iTerm 而不是 vscode 终端。

  1. Go to VSCode terminal and execute: Go 到 VSCode 终端并执行:

     echo "$PATH"
  2. Check where the mongo binary is located:检查 mongo 二进制文件的位置:

     which mongo brew info mongo
  3. Go to your zsh and add to your.zshrc file the path where mongo is located: Go 到您的 zsh 并将 mongo 所在的路径添加到 your.zshrc 文件:

     export PATH="$PATH:/opt/homebrew/bin"
  4. If you do not add the path you will still be able to run it like:如果您不添加路径,您仍然可以像这样运行它:

     /opt/homebrew/bin/mongo

I'm not sure why, but when I went directly into the.zshrc file and added this line我不知道为什么,但是当我直接进入 .zshrc 文件并添加了这一行时

export PATH="$PATH:/opt/homebrew/bin"

the command 'mongo' still didn't start the db.命令'mongo'仍然没有启动数据库。

BUT..但..

I figured it out.我想到了。 Instead of opening my.zshrc and editing it I just edited my path with this little line here with the path described by R2D2我没有打开 my.zshrc 并对其进行编辑,而是使用R2D2描述的路径在这里用这条小线编辑了我的路径

path+=/opt/homebrew/bin/

Command 'mongo' is working perfectly now!命令“mongo”现在工作正常!

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

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