I’ve been asked to post my solution for running the mongosh shell in VS Code. I’ll gladly do so, with the understanding that this is not specifically a solution to the OP’s question about “mongosh command not working in Bash shell”. I understand that the OP’s question has been resolved. Running mongosh in a Bash terminal was suboptimal to me, and running it in a VS Code terminal became my preferred solution; not least, because I’m also using this for learning web development. Assuming a problem-free installation of VS Code on Windows 10, my solution was really quite simple. Just add the mongosh.exe path to the sytem’s Path environment variable; in my case C:\Program Files\MongoDB\Shell\bin. Open a terminal in VS Code, which in my case by default runs Powershell. At the PS prompt, enter: mongosh. The terminal now runs the mongosh shell, and displays the usual mongosh prompt. Two advantages:

  1. I prefer to type closed brackets first, like:
    test> db.products.insertOne({})
    and then complete the command, like:
    test> db.products.insertOne({_id: 1, name: “Cool product”, price: 0.99})
    This requires moving the cursor back into the previously typed line. Although it also seems to work, at first sight, when running mongosh in Bash, executing the command returns an error.
  2. In a VS Code terminal running mongosh, I can use the up/down arrows to cycle through previous commands, and edit them as needed to quickly create a new command. This doesn’t work when running mongosh in Bash.