Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module './drivers' with mongoose only on the server

mongoose works fine on the computer

but on the server I get this error:

Error: Cannot find module './drivers'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.<anonymous> (/usr/local/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:59:21)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/var/www/html/WTV.com/node_modules/mongoose/lib/schema.js:5:16)
    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)
like image 399
coiso Avatar asked Aug 05 '15 14:08

coiso


People also ask

How to fix Cannot find module mongoose?

To solve the error "Cannot find module 'mongoose'", make sure to install the mongoose package by opening your terminal in your project's root directory and running the following command: npm i mongoose and restart your IDE and development server.

Can not find module mongodb?

The can't find module 'mongodb' error occurs, if you're trying to access a mongodb module that is not present inside your node_modules folder. To solve the error install the mongodb module in your project root directory by running npm install mongodb .


1 Answers

OK! I took me a while but I found the solution

  1. in commandline write: heroku config:set NODE_MODULES_CACHE=false --app
  2. make some change and push the project
  3. in commandline write: heroku config:set NODE_MODULES_CACHE=true --app

Good luck :)

like image 56
Gil SH Avatar answered Oct 30 '22 22:10

Gil SH