Fix module loading of third-party modules in the REPL by inheriting
module.paths from the REPL's parent module.
Commit ee72ee7 ("module,repl: remove repl require() hack") introduced
a regression where require() of modules in node_modules directories
no longer worked in the REPL (and fortunately only in the REPL.)
It turns out we didn't have test coverage for that but we do now.
Fixes: https://github.com/nodejs/node/issues/4208
PR-URL: https://github.com/nodejs/node/pull/4215
Reviewed-By: Roman Reiss <me@silverwind.io>
10 lines
377 B
JavaScript
10 lines
377 B
JavaScript
console.error(__filename);
|
|
console.error(module.paths.join('\n') + '\n');
|
|
// this should work, and get the one that doesn't throw
|
|
var assert = require('assert');
|
|
assert.equal(require('bar'), require('../bar.js'));
|
|
|
|
// this should work, and get the one in ./node_modules/asdf.js
|
|
assert.equal(require('asdf'), require('./node_modules/asdf.js'));
|
|
|
|
module.exports = 'eye catcher';
|