Note that there are some explanatory texts on larger screens.

plurals
  1. POnode.js: Why does NODE_DEBUG=1 not work? (trying to debug a require() error)
    text
    copied!<p>I have a directory structure like so:</p> <pre><code>project lib paperboy redis-client node-cookie srv main.js ... </code></pre> <p>I start main.js from the project directory:</p> <pre><code>$ node srv/main.js </code></pre> <p>In main.js, I can do:</p> <pre><code> paperboy = require('./lib/paperboy'); </code></pre> <p>However, this fails:</p> <pre><code> redis = require('./lib/redis-client'); </code></pre> <p>Similarly, if I start interactive node in the "project" directory, I can require paperboy, but not redis-client. The error I get is:</p> <pre><code>&gt; require('./lib/redis-client') Error: Cannot find module './lib/redis-client' at resolveModuleFilename (node.js:265:13) at loadModule (node.js:231:20) at require (node.js:291:14) ... </code></pre> <p>Looking at the source for resolveModuleFilename(), it attempts to print a debug string, that I don't see:</p> <pre><code>debug("looking for " + JSON.stringify(id) + " in " + JSON.stringify(paths)); </code></pre> <p>I have tried enabling this through export NODE_DEBUG=1, but I still don't see this debug print when trying to require.</p> <p>What am I doing wrong in trying to get this debug to print? And, second, why would paperboy load fine, but redis-client fail to be found?</p> <p>Additional info: Here's the full file/directory list in the "lib" directory:</p> <pre><code>lib lib/cookie-node lib/cookie-node/package.json lib/cookie-node/LICENSE.txt lib/cookie-node/README.markdown lib/cookie-node/example lib/cookie-node/example/ex1.js lib/cookie-node/index.js lib/redis-client lib/redis-client/package.json lib/redis-client/TODO.md lib/redis-client/examples lib/redis-client/examples/redis-version.js lib/redis-client/examples/using-kiwi.js lib/redis-client/examples/subscriber.js lib/redis-client/examples/publisher.js lib/redis-client/examples/.redis-version.js.swp lib/redis-client/examples/README.md lib/redis-client/seed.yml lib/redis-client/LICENSE lib/redis-client/test lib/redis-client/test/test_throw_from_callback.js lib/redis-client/test/test_shutdown_reconnect.js lib/redis-client/test/test.js lib/redis-client/test/sample.png lib/redis-client/.gitignore lib/redis-client/lib lib/redis-client/lib/redis-client.js lib/redis-client/README.md lib/paperboy lib/paperboy/package.json lib/paperboy/seed.yml lib/paperboy/LICENSE.txt lib/paperboy/example lib/paperboy/example/basic.js lib/paperboy/example/webroot lib/paperboy/example/webroot/img lib/paperboy/example/webroot/img/paperboy.jpg lib/paperboy/example/webroot/index.html lib/paperboy/index.js lib/paperboy/lib lib/paperboy/lib/paperboy.js lib/paperboy/README.md </code></pre> <p>The lib directories are unpacked .tar.gz files from github, re-named to match the module name from the package.json files.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload