0

I Can't figure out why heroku can't find mongoose module

enter image description here

user1744669
  • 141
  • 1
  • 7
  • fixed the issue. https://stackoverflow.com/questions/45064655/how-to-clean-cache-in-heroku-after-installing-dependencies/45073405#45073405 – user1744669 Jan 29 '19 at 18:42

2 Answers2

0

It's because mongoose is set as a devDependency. Heroku usually deploys things in production mode, which means development dependencies are not installed. You should set mongoose as a regular dependency in your package.json.

(You could also tell Heroku to run in development mode, but that's probably not the right solution since you almost certainly want mongoose to be available in production.)

RobertAKARobin
  • 3,933
  • 3
  • 24
  • 46
0

It's because mongoose is listed on devDependencies of your package.json.

By default Heroku will strip out the modules declared under devDependencies before deploying the application.

One way to solve this is move mongoose to dependencies on package.json. Other way is set NODE_ENV environment variable to other value than production that is the default, so Heroku will mantain the modules on devDependencies.