Follow
Follow

Debugging a Module Resolution Problem in Node

While trying to run my app on Node, I got the uncaught exception:

{"code":"MODULE_NOT_FOUND","path":".../package.json"}

Which obviously didn’t do much to tell me what imports were broken. (This project has a couple of different languages compiling down to javascript, so this ambiguous error may belong to my unique concoction of config files)

To debug it, I enabled debug logging of Node’s module system itself:

NODE_DEBUG=loader,module node app.js

After that, I could see that the last file Node logged about trying to load was the one that was missing.

Comments
Join the Discussion and Share Your Opinion
Add a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *