web-development-with-node-and-express
web-development-with-node-and-express copied to clipboard
mongoDB
"C:\Program Files (x86)\JetBrains\WebStorm 11.0.2\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" meadowlark.js { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version
!!! MONGOOSE WARNING !!!
This is an UNSTABLE release of Mongoose.
Unstable releases are available for preview/testing only.
DO NOT run this in production.
c:\Users\xvinc\Downloads\Compressed\web-development-with-node-and-express-master\ch13\meadowlark.js:89 var sessionStore = new MongoSessionStore({ url: credentials.mongo[app.get('env')].connectionString }); ^
TypeError: Cannot read property 'development' of undefined
at Object.
Process finished with exit code 1
Yes, you will have to upgrade Mongo for use in production. What is your question, exactly?
Also, it looks like you don't have an entry mongo
in your credentials.js
file (which is why you're getting the Cannot read property 'development
of undefined` error.
Hello, Ethan
I'm getting the same Cannot read property 'development' of undefined
and in my credentials.js I wrote:
mongo: {
development: {
connectionString: 'mongodb://<dbuser>:<dbpassword>@ds157833.mlab.com:57833/user';
}
production: {
connectionString: 'mongodb://<dbuser>:<dbpassword>@ds157833.mlab.com:57833/user';
}
}
Is my syntax wrong?
Hi, @Rikazavr, is that the entire contents of your credentials.js
file? If so, that's not going to export anything at all.... It will need to look something like this:
module.exports = {
mongo: {
development: { /*...*/ },
production: { /*...*/ },
},
}
Yes, now I got it.... Thank you for the quick response!
$ node meadowlark.js
Error: spawn mongod ENOENT
at _errnoException (util.js:992:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
at Function.Module.runMain (module.js:695:11)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
I get above message when I run the chapter 13 example.
@neihcnim what version of Node are you using? I'm afraid I have not been maintaining this repo (you'll have to wait for the 2nd edition for an updated one), and it hasn't kept up to date with the changes in Node. I just tried, and I was able to run the ch13 examples with Node 4.
PS, @neihcnim, you can use nvm for easy switching between Node versions!
I am using node js 8.11.2
After erasing my meadowlark.js and copying the original one. I hit a new error
events.js:183
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'length' of undefined
at C:\users\limmc\src\ethanb\ch13\meadowlark.js:121:18
at C:\users\limmc\src\ethanb\ch13\node_modules\mongoose\lib\model.js:4081:16
at C:\users\limmc\src\ethanb\ch13\node_modules\kareem\index.js:213:48
at C:\users\limmc\src\ethanb\ch13\node_modules\kareem\index.js:131:16
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
I solved this by checking for null with
if(vacations && vacations.length) return;
After solving this, I was able to start meadowlark.js . The next thing I need to do was place the schema name Vacation in the connection string. So far ch13 example is working for now.
Glad it's working for you now, @neihcnim ...sorry for the issues you've experienced.