dependents/node-filing-cabinet

configure NODE_PATH?

brumm opened this issue · 1 comments

brumm commented

Hey,

we're using something similar to https://gist.github.com/branneman/8048520#52-only-while-executing-node to prevent having to use long, relative paths when importing/requiring modules.

Is there a way to make filing cabinet aware of such a situation? I'm trying to build a dependency graph for a project that uses NODE_PATH=src and would like to be able to resolve something like import Foo from 'components/Foo' to /absolute/path/to/project/src/components/Foo.js

Hey! Thanks for contributing.

My initial hunch is that you might be able to add the env value of NODE_PATH to the list of require paths here:

appModulePath.addPath(moduleLookupDir);
.

You could try that by modifying that code deep within the consuming library (like dependency-tree or madge) and see if it works. If that doesn't work right away, the fix would definitely be in that region. Let me know what you find. I'm happy to review a PR that fixes the issue. Any help is appreciated.

Thanks.