directory-rest-nodejs icon indicating copy to clipboard operation
directory-rest-nodejs copied to clipboard

error in employee.js

Open yu521088 opened this issue 12 years ago • 3 comments

when i run node server.js, it run into error with below error message:

    db = mongoClient.db("employeedb09");
                     ^
TypeError: Cannot call method 'db' of null
    at C:\Documents and Settings\a531320\My Documents\rest\routes\employee.js:7:22
    at C:\Documents and Settings\a531320\My Documents\rest\node_modules\mongodb\lib\mongodb\mongo_client.js:101:20
    at C:\Documents and Settings\a531320\My Documents\rest\node_modules\mongodb\lib\mongodb\db.js:267:16
    at null.<anonymous> (C:\Documents and Settings\a531320\My Documents\rest\node_modules\mongodb\lib\mongodb\connection\server.js:546:7)
    at EventEmitter.emit (events.js:106:17)
    at null.<anonymous> (C:\Documents and Settings\a531320\My Documents\rest\node_modules\mongodb\lib\mongodb\connection\connection_pool.js:140:15)
    at EventEmitter.emit (events.js:98:17)
    at Socket.<anonymous> (C:\Documents and Settings\a531320\My Documents\rest\node_modules\mongodb\lib\mongodb\connection\connection.js:478:10)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:441:14

yu521088 avatar Aug 12 '13 06:08 yu521088

You have to check that mongodb is running. If you haven't, install mongodb from http://www.mongodb.org/downloads

alerios avatar Aug 22 '13 05:08 alerios

Thx @alerios , finally get it works, great!

yu521088 avatar Aug 22 '13 07:08 yu521088

@ccoenraets, I too ran into the same mistake and was stupid enough to waste an hour. Could you please add this instruction to the Read Me.

viswanathct avatar Oct 26 '13 13:10 viswanathct