NPM install mongodb breaks


Thanks for your replies. I tried the exact same commands today (saved in a textfile from yesterday) and now MongoDB starts ok.


Setting Up MongoDB

Yet another problem occurred. I can indeed connect to MongoDB using Mongoose. But I cannot connect using the native node.js - mongodb driver (dont want to use ORM at the moment).

Reading the documentation I understand that it should be part of the mongodb package - what might be the issue here?

When Im trying to:
// Retrieve
var MongoClient = require('mongodb').MongoClient;

I’m getting an error:

Error: Cannot find module 'mongodb'                                                                                                
    at Function.Module._resolveFilename (module.js:338:15)                                                                         
    at Function.Module._load (module.js:289:25)                                                                                    
    at Module.require (module.js:366:17)                                                                                           
    at require (module.js:385:17)                                                                                                  
    at Object.<anonymous> (/home/ubuntu/workspace/mongoose_db_connect.js:9:19)                                                     
    at Module._compile (module.js:435:26)                                                                                          
    at Object.Module._extensions..js (module.js:442:10)                                                                            
    at Module.load (module.js:356:32)                                                                                              
    at Function.Module._load (module.js:313:12)                                                                                    
    at Function.Module.runMain (module.js:467:10)               

Running the :

~/workspace $ npm install mongodb --save

Gives me tons of errors:

~/workspace $ npm install mongodb --save
npm ERR! not a package /home/ubuntu/workspace/mongodb
npm ERR! addLocal Could not install /home/ubuntu/workspace/mongodb
npm ERR! Linux 4.2.0-c9
npm ERR! argv "/home/ubuntu/.nvm/versions/node/v4.2.4/bin/node" "/home/ubuntu/.nvm/versions/node/v4.2.4/bin/npm" "install" "mongodb" "--save"
npm ERR! node v4.2.4
npm ERR! npm  v2.14.12
npm ERR! path /tmp/npm-7120-34a7f418/unpack-522eb0e6cd59/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open '/tmp/npm-7120-34a7f418/unpack-522eb0e6cd59/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ubuntu/workspace/npm-debug.log


Hmm, I’m testing things out right now but I just ran through this process for running mongo and then after I ran it I tried using this Mongoose tutorial and everything looks good. Here’s the public workspace where I did that: Mongo + Mongoose.

Upon trying to install Mongo I’ve run into the same issue so I’ve broken these out into a separate topic and filed a bug report. I’ll let you know when I have more on this. Perhaps it’d also be useful to have quick guides on getting Mongo working with Node and Mongoose working with Node so I can add those as well.