Mongodb events.js:85



我一直在做这个项目。我面临着一些问题,我无法解决后,我真的很努力。如果你们能帮我,我会很感激的。我试图连接到mongodb数据库使用node.js,但每当我启动服务器,我得到以下错误。我不知道如何解决这个错误。

{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
The magic happens on port 8080
Connected correctly to server
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: failed to connect to [undefined:27017]
    at null.<anonymous> (C:UsersAdminDesktopAppslinked-up 0.0.1easy-node-authentication-masternode_modulesmongoosenode_modulesmongodblibmongodbconnectionserver.js:556:74)
    at emit (events.js:118:17)
    at null.<anonymous> (C:UsersAdminDesktopAppslinked-up 0.0.1easy-node-authentication-masternode_modulesmongoosenode_modulesmongodblibmongodbconnectionconnection_pool.js:156:15)
    at emit (events.js:110:17)
    at Socket.<anonymous> (C:UsersAdminDesktopAppslinked-up 0.0.1easy-node-authentication-masternode_modulesmongoosenode_modulesmongodblibmongodbconnectionconnection.js:534:10)
    at Socket.emit (events.js:107:17)
    at net.js:950:16
    at process._tickCallback (node.js:355:11)

感谢您的宝贵时间和考虑

您确定在系统本地启动并运行mongodb吗?

要将本地路径映射到mongodb,请尝试以下命令

[location of mongodb]/bin/mongod——dbpath "specify location of database"

您是否像下面这样编写代码?

mongoose.connect(configDB.url); // connect to database

我猜你没有设置你的configDB。url。

用您的db url设置它,如'localhost:27017/myDatabase'

最新更新