directory-rest-nodejs
directory-rest-nodejs copied to clipboard
error in employee.js
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
You have to check that mongodb is running. If you haven't, install mongodb from http://www.mongodb.org/downloads
Thx @alerios , finally get it works, great!
@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.