Debugging Node JS

Debugging how node searches for modules to load (require)

Say you've got a piece of JavaScript that says:

var SchemaAssembler = require("my-module/myComponent").SchemaAssembler;

And this fails to load, node giving a mediocre:

{ Error: Cannot find module my-module/myComponent }

You can investigate this by setting the environment variable NODE_DEBUG:

export NODE_DEBUG=module
# node ....main.js ....
MODULE 14489: Module._load REQUEST my-module/myComponent parent:

MODULE 14489: looking for "my-module/myComponent" in

Licensed under CC BY Creative Commons License ~ ✉ torstein.k.johansen @ gmail ~ 🐘 ~ 🐦 @torsteinkrause