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

Cannot find module 'mongodb' #21

Closed
mhurwicz opened this issue Nov 5, 2015 · 3 comments
Closed

Cannot find module 'mongodb' #21

mhurwicz opened this issue Nov 5, 2015 · 3 comments

Comments

@mhurwicz
Copy link

mhurwicz commented Nov 5, 2015

I had some problems on install:
#20

But it seemed that mongo was available:

mhurwicz:~/workspace $ mongod --version
db version v2.6.11
2015-11-05T19:20:17.076+0000 git version: d00c1735675c457f75a12d530bee85421f0c5548

But now trying to execute this code:

  var mongo = require('mongodb').MongoClient
    mongo.connect('mongodb://localhost:27017/learnyoumongo', function(err, db) {
      // db gives access to the database
    })

I get the following:

module.js:338
    throw err;
    ^

Error: Cannot find module 'mongodb'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/ubuntu/workspace/find.js:1:78)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
@evanlucas
Copy link
Owner

You'll need to npm install mongodb

@mhurwicz
Copy link
Author

mhurwicz commented Nov 6, 2015

Evan - Thanks for the reply. That seems to have worked. For others who may run across this, on Cloud 9 I also got things working by editing package.JSON to add mongodb as a dependency:

  "dependencies": {
    "async": "~0.2.8",
    "express": "~3.2.4",
    "socket.io": "~0.9.14",
    "mongodb":"~2.6.11"
  }

and then using npm link mongodb

I based this solution on this:
http://stackoverflow.com/questions/14226410/node-js-cannot-find-module-mongodb

@Buildit978
Copy link

Thank You

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

3 participants