Node.js 启动节点服务器时无法连接到mongodb
我正在尝试在我的虚拟机上本地运行我的节点应用程序 当我运行命令时:Node.js 启动节点服务器时无法连接到mongodb,node.js,mongodb,compiler-errors,connection,Node.js,Mongodb,Compiler Errors,Connection,我正在尝试在我的虚拟机上本地运行我的节点应用程序 当我运行命令时: sudo NODE_ENV=XYZ PORT=80节点服务器/app.js 我得到一个错误: /node_modules/mongo oplog/node_modules/mongodb/lib/mongodb/mongo_client.js:378 失误 ^错误:连接已关闭 在空。(/node_modules/mongo oplog/node_modules/mongodb/lib/mongodb/connection/ser
sudo NODE_ENV=XYZ PORT=80节点服务器/app.js
我得到一个错误:
/node_modules/mongo oplog/node_modules/mongodb/lib/mongodb/mongo_client.js:378
失误
^错误:连接已关闭
在空。(/node_modules/mongo oplog/node_modules/mongodb/lib/mongodb/connection/server.js:605:24)
在发出时(events.js:92:17)
在空。(/node_modules/mongo oplog/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:155:15)
在发出时(events.js:98:17)
在插座上。(//node_modules/mongo oplog/node_modules/mongodb/lib/mongodb/connection/connection.js:528:12)
在Socket.emit(events.js:95:17)
我的mongoDB运行良好,我可以用robomongo连接到本地db
非常感谢您的帮助。能否在node.js文件中显示负责连接MongoDB实例的代码?绝对需要app.js和连接字符串为什么不使用mongoose插件?它的使用非常简单,可以消除错误