Unless I'm mistaken I think I need to add the *mongoose* folder to the * node_modules* folder and rather that putting the command *npm install* put *npm install mongoose* instead. The error seems to have gone now.
On Wednesday, 28 November 2012 23:06:20 UTC, Dave Johnson wrote: > Hi, > > I will apologise for this long winded post but after quite a bit of > Googling I think needs must. > > I am making my through a node.js book <http://nodejsbook.io/> and Iam > working through the chapter that introduces the MongoDB. Firstly, I have > installed MongoDB and seems to be running as a service on my Windows 7 PC. > Also I have installed MongoVUE and this seems to installed ok. > > The purpose of this exercise (see attached zip) is to just connect to the > MongoDB. > > So in the node.js command prompt (Run as administrator) I use the > following commands: > > 1. express connect_to_mongo > 2. cd connect_to_mogo > 3. npm install > > So in my root folder I now have *connect_to_mongo* folder with the > installation going ok > > Then the package.json is edited to: > { > "name":"application-name", > "version":"0.0.1", > "private":true, > "dependencies":{ > "express":"2.5.1", > "jade":">= 0.0.1", > "mongoose":">= 2.3.1" > } > } > > Then the app.js is edited to include: > var express = require('express'), > routes = require('./routes'), > mongoose = require('mongoose'); > mongoose.connect('mongodb://localhost/todo_development', function(err) { > if (!err) { > console.log('connected to MongoDB'); > } else { > throw err; > } > }); > > With all of this saved I then try to fire this up with: *node app.js* and > get the following error: > > C:\Users\Dave > Johnson\Desktop\shapeshed-nodejsbook.io.examples-e2ece11\hour08\ex > ample04\connect_to_mongo>node app.js > module.js:340 > throw err; > ^ > Error: Cannot find module 'mongoose' > at Function.Module._resolveFilename (module.js:338:15) > at Function.Module._load (module.js:280:25) > at Module.require (module.js:362:17) > at require (module.js:378:17) > at Object.<anonymous> (C:\Users\Dave Johnson\Desktop\ > shapeshed-nodejsbook.io > .examples-e2ece11\hour08\example04\connect_to_mongo\app.js:8:16) > at Module._compile (module.js:449:26) > at Object.Module._extensions..js (module.js:467:10) > at Module.load (module.js:356:32) > at Function.Module._load (module.js:312:12) > at Module.runMain (module.js:492:10) > > Unless I am missing something the book only seems to ask for *mongoose*to be > listed as dependancy and then reference it in the app.js. > > But I even tried adding it with *express mongoose* and then installing it > in 1. root folder, 2. the connect_to_mongo folder & 3. the node_modules > folder and still get the same error. > > I hope I am making sense and if so please help me if you can. > > Thanks, Dave. > > > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
