Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongoDB #68

Open
xvinc opened this issue Mar 1, 2016 · 9 comments
Open

mongoDB #68

xvinc opened this issue Mar 1, 2016 · 9 comments

Comments

@xvinc
Copy link

xvinc commented Mar 1, 2016

"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

@EthanRBrown
Copy link
Owner

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.

@Rikazavr
Copy link

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?

@EthanRBrown
Copy link
Owner

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

@Rikazavr
Copy link

Rikazavr commented Sep 1, 2017

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

@neihcnim
Copy link

neihcnim commented Jul 23, 2018

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

@EthanRBrown
Copy link
Owner

@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
Copy link
Owner

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

@neihcnim
Copy link

neihcnim commented Jul 24, 2018

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.

@EthanRBrown
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants