Reputation: 9732
I'm trying to deploy a simple node.js server to Heroku, but keep running into this error:
Error: Cannot find module 'morgan'
I'm using morgan
to do some HTTP logging, i have morgan in my package.json
under the devDependencies (along with many others)
"devDependencies": {
"morgan": "~1.5.0"
}
I can do npm install
locally and start the server without any issues, but when I deploy to Heroku I keep running into that error once it starts the server.
Is there anything I'm forgetting?
Upvotes: 2
Views: 3599
Reputation: 1387
By default Heroku execute npm install --production
which avoid install devDependencies, quoting literally documentation of Heroku.
The Heroku node buildpack runs npm install --production, which doesn’t install devDependencies in your package.json file. If you wish to install development dependencies when deploying to Heroku, you should move your build dependencies (such as grunt plugins) from devDependencies to dependencies in package.json.
If you use the Morgan module, you need move it to 'dependencies'.
Source: https://devcenter.heroku.com/articles/nodejs-support
Upvotes: 13