By NormalizeWeb
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
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!
Accepted Answer
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 using
mongoose` driver. Maybe a simple grep command can help you there:
- 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
)
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.