我无法使用 VScode 连接到 mongodb shell。如果我通过转到 bin 的提取位置打开它,它运行良好。
每次我尝试打开 mongoDB shell 时都会弹出此错误,并且我已将环境变量设置为 mongodb shell 的位置
环境变量位置:'C:\Program Files\mongosh-1.8.2-win32-x64 中'
我在 VScode 中使用官方 MongoDB 进行 VS Code 扩展
mongosh $Env:MDB_CONNECTION_STRING;
mongosh : The term 'mongosh' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ mongosh $Env:MDB_CONNECTION_STRING;
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (mongosh:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我有同样的问题,我是这样解决的: 1 -确保您在系统环境变量的文件路径末尾添加了 \。 2 - 重新加载 vscode。 您可以参考此链接了解如何安装 mongosh:https://www.mongodb.com/docs/mongodb-shell/install/#std-label-mdb-shell-install