Question

My app throws exeception for mongodb module not found.

Hello Team,

I have application deployed on Ubuntu 16.04 with node js, mongodb, mongoose & express js. Until y’day my app was up and running with no issues. When I pushed the updates to server and restarted the server using pm2 it started giving below error :

​ Error: Cannot find module ‘mongodb’ at Function.Module._resolveFilename (module.js:325:15) at Function.Module._load (module.js:276:25) at Function._load (/usr/local/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/home/sumit/www/bulawaa/node_modules/mongoose/lib/drivers/node-mongodb-native/binary.js:6:14) at Module._compile (module.js:409:26) at Object.Module._extensions…js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12)

I have mongoose npm package installed, trying to figure out what changed in mongodb drivers that is causing this issue. Due to this my app is down.

Can some one help me get to the cause. Look forward to hear from you.

Kind Regards, Sumit


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

What about trying to update all npm packages you have with npm install? You should execute it in directory where packages.json is located.

Didn’t you by mistake called somewhere in code require('monogodb') instead of require(‘mongoose’)if you are usingmongoose` driver. Maybe a simple grep command can help you there:

  1. grep -r "require('monogodb')" .

In last resort maybe you can try removing all node modules (node_modules), clearing out npm cache (npm cache clear) and install all modules again (npm install)