Make the repl respect node_modules folders.

This is important so that in the future, this will work:

    $ cd ~/dev/js/some-project
    $ npm install redis
    $ node
    > require.resolve('redis')
    '/Users/isaacs/dev/js/some-project/node_modules/redis/index.js'
This commit is contained in:
isaacs 2011-02-11 15:53:22 -08:00 committed by Ryan Dahl
parent fe838611f6
commit f07041e6cd

View File

@ -36,6 +36,9 @@ if (process.platform != 'win32') {
// hack for require.resolve("./relative") to work properly.
module.filename = process.cwd() + '/repl';
// hack for repl require to work properly with node_modules folders
module.paths = require('module')._nodeModulePaths(module.filename);
function resetContext() {
context = vm.createContext();