module: fix wrong condition in early return logic for node_module path by hefangshi · Pull Request #6670 · nodejs/node

@mscdex added the module

Issues and PRs related to the module subsystem.

label

May 10, 2016
The `p < nmLen` condition will fail when a module's name is end with
`node_modules` like `foo_node_modules`. The old logic will miss the
`foo_node_modules/node_modules` in node_modules paths.

TL;TR, a module named like `foo_node_modules` can't require any module
 in the node_modules folder.
Manual parsers didn't handle the root path on both platform, so push
driver root node_modules when colon is matched in windows to avoid
parse dirver name and direct push `/node_modules` into paths in posix.

@hefangshi

Add a real world global node_modules path test case come from npm's
dependency to make test more effective.

evanlucas pushed a commit that referenced this pull request

Aug 9, 2016
The `p < nmLen` condition will fail when a module's name is end with
`node_modules` like `foo_node_modules`. The old logic will miss the
`foo_node_modules/node_modules` in node_modules paths.

TL;TR, a module named like `foo_node_modules` can't require any module
 in the node_modules folder.

Fixes: #6679
PR-URL: #6670
Reviewed-By: Evan Lucas <evanlucas@me.com>

cjihrig pushed a commit that referenced this pull request

Aug 10, 2016
The `p < nmLen` condition will fail when a module's name is end with
`node_modules` like `foo_node_modules`. The old logic will miss the
`foo_node_modules/node_modules` in node_modules paths.

TL;TR, a module named like `foo_node_modules` can't require any module
 in the node_modules folder.

Fixes: #6679
PR-URL: #6670
Reviewed-By: Evan Lucas <evanlucas@me.com>