Node v0.8.5 REPL: cannot find a module when an installed npm module is required

I have a node application with a file package.jsondeclaring my dependencies.

I started npm installto install these deps in a local folder node_modules, and when I run my application everything works fine.

The problem is that I am trying to identify some new features by activating node REPL:

$ node           
> require('hubot');
Error: Cannot find module 'hubot'

In REPL, he doesn't seem to know what to look inside node_modules. Is this the expected behavior or too weird?

+5
source share
1 answer

You can set the env variable NODE_DEBUGto see the paths that have been checked with node:

export NODE_DEBUG=module
> require('toto')
Module._load REQUEST  toto parent: repl
looking for "toto" in ["/Users/laurent/repl/node_modules","/Users/laurent/node_modules","/Users/node_modules","/node_modules","/lusr/local/bin/node","/Users/laurent/.node_modules","/Users/laurent/.node_libraries","/usr/local/lib/node"]
+6
source

All Articles