(versionsDir, subdir, out)
| 38 | // active version is preferred when a user has multiple Node versions |
| 39 | // installed. |
| 40 | function _scanVersionedNodeModules(versionsDir, subdir, out) { |
| 41 | let entries; |
| 42 | try { |
| 43 | entries = fs.readdirSync(versionsDir, { withFileTypes: true }); |
| 44 | } catch { |
| 45 | return; |
| 46 | } |
| 47 | const dirs = entries |
| 48 | .filter((e) => e.isDirectory && e.isDirectory()) |
| 49 | .map((e) => { |
| 50 | const full = path.join(versionsDir, e.name); |
| 51 | let mtime = 0; |
| 52 | try { mtime = fs.statSync(full).mtimeMs; } catch {} |
| 53 | return { full, mtime }; |
| 54 | }) |
| 55 | .sort((a, b) => b.mtime - a.mtime); |
| 56 | for (const d of dirs) { |
| 57 | out.push(path.join(d.full, subdir, 'node_modules')); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | // Build the require.resolve paths array. All entries are user/system-scoped |
| 62 | // install roots — process.cwd() is intentionally excluded for the same |
no outgoing calls
no test coverage detected