diff --git a/src/commands/script-loader.ts b/src/commands/script-loader.ts index f2a7bda280..e8459b0cf6 100644 --- a/src/commands/script-loader.ts +++ b/src/commands/script-loader.ts @@ -484,7 +484,7 @@ async function getFilenamesByPattern(pattern: string): Promise { // Determine the project root // https://stackoverflow.com/a/18721515 function getPkgJsonDir(): string { - for (const modPath of module.paths) { + for (const modPath of (module.paths || [])) { try { const prospectivePkgJsonDir = path.dirname(modPath); fs.accessSync(modPath, fs.constants.F_OK);