0

I am a beginner in node.js and express and I have been following http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/ as a reference to get started. I am building a small app to display data from my mongodb collection using jade.However,i get these errors in npm start.

> nodetest1@0.0.0 start C:\node\nodetest1
> node ./bin/www

{ Error: Cannot find module '../build/Release/bson'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\node\nodetest1\node_modules\bson\ext\index.js:15:10)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3) code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
C:\node\nodetest1\app.js:50
app.use('/', routes);
             ^


ReferenceError: routes is not defined
at Object.<anonymous> (C:\node\nodetest1\app.js:50:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\node\nodetest1\bin\www:7:11)
at Module._compile (module.js:570:32)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nodetest1@0.0.0 start: `node ./bin/www
enter code here`npm ERR! Exit status 1
enter code here`npm ERR!
enter code here`npm ERR! Failed at the nodetest1@0.0.0 start script.
enter code here`npm ERR! This is probably not a problem with npm. There is likely additional code logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2017-09-16T17_48_47_843Z-debug.log
PS C:\node\nodetest1>

I tried searching for the error in npm Official Docs but and even updated my npm to the latest version.But this is the latest set of errors I am getting.No Clues. Any help or hint would be highly helpful.

  • From the looks of it, in your app.js you're missing routes import, put this at the top of the file, could help: var routes=require('routes'); – pegla Sep 16 '17 at 18:32
  • Okay,thanks I added this 'var routes = require('./routes/index')' which was missing.But now I get Error: Cannot find module '../build/Release/bson' – Aditya Murli Krishnan Sep 16 '17 at 18:40
  • same thing var bson = require('bson'); – pegla Sep 16 '17 at 18:42
  • did you do in console: npm install bson – pegla Sep 16 '17 at 18:45
  • no i didnt...also the bson thing was a warning not an error...but nowwhen I do localhost:3000 I get 'unexpected token "pipeless-text" ' and then the entire jade code gets displayed. – Aditya Murli Krishnan Sep 16 '17 at 19:01
  • I would suggest you go from start of the tutorial again, maybe you missed something or didn't define dependencies? After you define dependencies (have package.json same as in tutorial) switch to folder and do npm install Also try finding some more recent tutorial, this one is from 2 years ago, lots of things changed in last 2 years. – pegla Sep 16 '17 at 19:07
  • Okay..thnx for ur help – Aditya Murli Krishnan Sep 16 '17 at 19:17

0 Answers0