web-development-with-node-and-express icon indicating copy to clipboard operation
web-development-with-node-and-express copied to clipboard

mongoDB

Open xvinc opened this issue 8 years ago • 9 comments

"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. (c:\Users\xvinc\Downloads\Compressed\web-development-with-node-and-express-master\ch13\meadowlark.js:89:66) at Module._compile (module.js:398:26) at Object.Module._extensions..js (module.js:405:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Function.Module.runMain (module.js:430:10) at startup (node.js:141:18) at node.js:980:3

Process finished with exit code 1

xvinc avatar Mar 01 '16 07:03 xvinc

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.

EthanRBrown avatar Mar 01 '16 16:03 EthanRBrown

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?

Rikazavr avatar Aug 31 '17 20:08 Rikazavr

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: { /*...*/ },
  },
}

EthanRBrown avatar Aug 31 '17 20:08 EthanRBrown

Yes, now I got it.... Thank you for the quick response!

Rikazavr avatar Sep 01 '17 10:09 Rikazavr

$ 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 avatar Jul 23 '18 09:07 neihcnim

@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.

EthanRBrown avatar Jul 23 '18 16:07 EthanRBrown

PS, @neihcnim, you can use nvm for easy switching between Node versions!

EthanRBrown avatar Jul 23 '18 16:07 EthanRBrown

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.

neihcnim avatar Jul 24 '18 00:07 neihcnim

Glad it's working for you now, @neihcnim ...sorry for the issues you've experienced.

EthanRBrown avatar Jul 24 '18 20:07 EthanRBrown