简体   繁体   中英

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.

Now when I try to start the db with command 'mongo' I get a return 'zsh: command not found: mongo'

the command works perfectly fine in the built-in terminal for VSCode.

would like to be able to use iTerm exclusively instead of the vscode terminal.

  1. Go to VSCode terminal and execute:

     echo "$PATH"
  2. Check where the mongo binary is located:

     which mongo brew info mongo
  3. Go to your zsh and add to your.zshrc file the path where mongo is located:

     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

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

the command 'mongo' still didn't start the db.

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

path+=/opt/homebrew/bin/

Command 'mongo' is working perfectly now!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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