spbooks / NODEJS1

Jump Start Node.js, code archive
57 stars 101 forks source link

Uncaught exception in chapter01 code #1

Open pmalek opened 11 years ago

pmalek commented 11 years ago

I am using Node 0.8.17 if that matters and while doing npm install in main directory of chapter01 after node app.js I get this:

$node app.js Express server listening on port 3000 in development mode

/home/user/programming/nodejs/NODEJS1/chapter01/authentication/node_modules/mongoose/lib/utils.js:413 throw err; ^ Error: Uncaught, unspecified 'error' event. at NativeConnection.EventEmitter.emit (events.js:73:15) at Model.init (/home/user/programming/nodejs/NODEJS1/chapter01/authentication/node_modules/mongoose/lib/model.js:554:31) at exports.tick (/home/user/programming/nodejs/NODEJS1/chapter01/authentication/node_modules/mongoose/lib/utils.js:408:16) at Db.ensureIndex (/home/user/programming/nodejs/NODEJS1/chapter01/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1066:28) at Db.indexInformation (/home/user/programming/nodejs/NODEJS1/chapter01/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1200:28) at Cursor.toArray (/home/user/programming/nodejs/NODEJS1/chapter01/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:124:30) at Cursor.each (/home/user/programming/nodejs/NODEJS1/chapter01/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:166:32) at Cursor.nextObject.self.queryRun (/home/user/programming/nodejs/NODEJS1/chapter01/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:441:39) at Cursor.close (/home/user/programming/nodejs/NODEJS1/chapter01/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:687:5) at Cursor.nextObject.commandHandler (/home/user/programming/nodejs/NODEJS1/chapter01/authentication/node_modules/mongoose/node_modules/mongodb/lib/mongodb/cursor.js:441:21)

wreilly commented 11 years ago

I think I've seen the exact same error (node_modules/mongoose/lib/utils.js:413) triggered upon restarting the app per the book on page 15.

The book back on page 13 has a single extra space that, once removed, removed this error.

BOOK PAGE 13: var address = ' @dbh42.mongolab.com:27427/nockmarket';

I at first replicated that leading space (don't ask me why) for my own mongolab database URI, hit the error, got unhappy, then thought to come back and get rid of that space, and it worked.

CORRECTED (No Space): var address = '@dbh42.mongolab.com:27427/nockmarket';

Perhaps you never inserted that space into your code and something else is hitting the error ---

Best, William Reilly

snehawatharkar commented 9 years ago

I removed the space and checked. But it is not working for me.. Can anyone help me with this..

mornepretorius commented 8 years ago

@snehawatharkar: Double check the version of mongoose you are running. I had the same issue and it turns out the tutorial I was following used a version "older than time itself". I updated the version in my package.json to version 4.6.0. ran the 'npm update' command in the app directory and it sorted my issue.