"Cannot find module" in Node.js at runtime

Issue

Your Node.js app builds successfully but, when it's run, you get a "cannot find module" error like:

Error: Cannot find module 'foobar'

Resolution

First, you should temporarily disable any module caching:

$ heroku config:set NODE_MODULES_CACHE=false

Next, you should ensure that you aren't accidentally checking your modules into git.

Finally, you should check to ensure that your dependencies are correctly listed in package.json.

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
Terms of Service Privacy Cookies © 2018 Salesforce.com