Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module-deps seems incompatible with node-resolve #149

Open
strugee opened this issue Jul 16, 2018 · 0 comments
Open

module-deps seems incompatible with node-resolve #149

strugee opened this issue Jul 16, 2018 · 0 comments

Comments

@strugee
Copy link

strugee commented Jul 16, 2018

See https://stackoverflow.com/q/51347558/1198896 for the detailed background, but basically, given the following minimal testcase:

test.js:

require('./test2.js');

test2.js: (empty)

test3.js:

var resolve = require('resolve'),
    mdeps = require('module-deps'),
    through2 = require('through2');

var md = mdeps({
        resolve: resolve
});

md.end(require.resolve('./test.js'));

Running test3.js creates this output:

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: Cannot find module './test2.js' from '/Users/alex/Development/audittool/test.js'
    at /Users/alex/Development/audittool/node_modules/resolve/lib/async.js:65:35
    at load (/Users/alex/Development/audittool/node_modules/resolve/lib/async.js:84:43)
    at onex (/Users/alex/Development/audittool/node_modules/resolve/lib/async.js:109:17)
    at /Users/alex/Development/audittool/node_modules/resolve/lib/async.js:12:69
    at FSReqWrap.oncomplete (fs.js:152:21)

The problem seems to be that node-resolve is not getting the correct basedir in its options object. Modifying node_modules/module-deps/index.js to insert if (parent.package) parent.basedir = parent.package.__dirname; on line 170 (right before the self.resolver() call) appears to fix this issue. I would PR but I don't know the source well enough to judge whether that's actually the correct place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant