Mongoose: Error cannot find module debugging

I am building a basic MEAN webapp and new to the stack. The interface works for me, but as soon as I add the following lines to app.js:

var mongoose = require('mongoose'); require('./models/test'); mongoose.connect('mongodb://localhost:3000/design-data-test'); 

I get the following error in the terminal:

 Error: Cannot find module 'debug' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (/Users/username/node_modules/mongoose/node_modules/mquery/lib/mquery.js:11:13) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) 

And all my front end code stops working. Mongodb runs on the default port.

How can I solve this error?

+5
source share
2 answers

I think this can happen if you have a child dependency on debug through another package (e.g. express or mongoose ), but you did not provide dependency package.json files with the application deployed that makes node.js unable to find debug .

+1
source

For future visitors: You probably have no addiction. Make sure you run this first:

 npm install 

... before starting the application using npm start or node <app>

0
source

All Articles