How do I fix a missing module in my package.json?


A Node.js build fails because of a missing module, which usually looks like:

Error: Cannot find module 'foo'


You can automatically update your package.json to include a missing module with the --save --save-exact flags for npm. For example, if the 'foo' module is missing, and you want to use version 1.2.3:

$ npm install --save --save-exact foo@1.2.3
$ git commit -am 'track foo@1.2.3 in package.json'
$ git push heroku master

For more information, read our article on Troubleshooting untracked dependencies

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support