lib/resolver/package.js
function resolveNodeModules(pkgpath) {
  let dir = pkgpath;
  let dirs = [];
  let depth = maxFileSystemDepth;
  let parent;
  let nodeModulespath;

  while (true) {
    parent = path.dirname(dir);
    // Stop if we hit max file system depth or root
    // Convert to lowercase to fix problems on Windows
    if (!--depth || parent.toLowerCase() === dir.toLowerCase()) {
      break;
    }

    nodeModulespath = path.resolve(dir, 'node_modules');

    if (exists(nodeModulespath)) dirs.push(nodeModulespath);

    // Walk
    dir = parent;
  }

  return dirs;
}
function resolveNodeModules(pkgpath) {
  let dir = pkgpath;
  let dirs = [];
  let depth = maxFileSystemDepth;
  let parent;
  let nodeModulespath;

  while (true) {
    parent = path.dirname(dir);
    // Stop if we hit max file system depth or root
    // Convert to lowercase to fix problems on Windows
    if (!--depth || parent.toLowerCase() === dir.toLowerCase()) {
      break;
    }

    nodeModulespath = path.resolve(dir, 'node_modules');

    if (exists(nodeModulespath)) dirs.push(nodeModulespath);

    // Walk
    dir = parent;
  }

  return dirs;
}
function resolveNodeModules ( pkgpath ) { let dir = pkgpath ; let dirs = [ ] ; let depth = maxFileSystemDepth ; let parent ; let nodeModulespath ; while ( true ) { parent = path . dirname ( dir ) ; // Stop if we hit max file system depth or root // Convert to lowercase to fix problems on Windows if ( ! -- depth || parent . toLowerCase ( ) === dir . toLowerCase ( ) ) { break ; } nodeModulespath = path . resolve ( dir , 'node_modules' ) ; if ( exists ( nodeModulespath ) ) dirs . push ( nodeModulespath ) ; // Walk dir = parent ; } return dirs ; }
Gather all node_modules directories reachable from 'pkgpath'
@param {String} pkgpath
@returns {Array}
Gather all node_modules directories reachable from pkgpath