"Cannot find module" in Node.js at runtime


Yarn is better then npm at identifying missing modules, but both of them can make mistakes from time-to-time with existing node_modules directories.

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. Yarn does this automatically, but npm does not.