diff --git a/lib/util.js b/lib/util.js index 91cab01e1..e255a67b5 100644 --- a/lib/util.js +++ b/lib/util.js @@ -66,14 +66,14 @@ function stringifyPrefix(o, n) { } // Includes support for npm '@org/name' packages -// Regex: .*?node_modules\/(@[^\/]*\/[^\/]*|[^\/]*).* -// Tests: https://regex101.com/r/lW2bE3/4 +// Regex: .*?node_modules(?!.*node_modules)\/(@[^\/]*\/[^\/]*|[^\/]*).* +// Tests: https://regex101.com/r/lW2bE3/6 var moduleRegex = new RegExp( - '.*?node_modules' + path.sep + - '(@[^' + path.sep + - ']*' + path.sep + - '[^' + path.sep + - ']*|[^' + path.sep + + '.*?node_modules(?!.*node_modules)\\' + path.sep + + '(@[^\\' + path.sep + + ']*\\' + path.sep + + '[^\\' + path.sep + + ']*|[^\\' + path.sep + ']*).*' );