简体   繁体   中英

Mongodb events.js:85

I am working on this project since long. I am facing some problem which I am unable to solve after trying really hard. I would really appreciate if you guys can help me. I am trying to connect to mongodb database using node.js but whenever I start server I get following error. And I have no idea how to solve that error.

{ [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:\Users\Admin\Desktop\Apps\linked-up 0.0.1\easy-node-authentication-master\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js:556:74)
    at emit (events.js:118:17)
    at null.<anonymous> (C:\Users\Admin\Desktop\Apps\linked-up 0.0.1\easy-node-authentication-master\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection_pool.js:156:15)
    at emit (events.js:110:17)
    at Socket.<anonymous> (C:\Users\Admin\Desktop\Apps\linked-up 0.0.1\easy-node-authentication-master\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection.js:534:10)
    at Socket.emit (events.js:107:17)
    at net.js:950:16
    at process._tickCallback (node.js:355:11)

Thank you for your time and consideration

Are you sure you are up and running mongodb locally in the system ?

To map local path to mongodb try the following command

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

Do you write you code like below?

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

I guess you did't set your configDB.url .

set it with your db url like 'localhost:27017/myDatabase'

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