{"record":{"id":"b5e63fdd185bd9aa","repo":"windmill-labs/windmill","slug":"npm-install-failed-with-exit-code-code","errorCode":null,"errorMessage":"npm install failed with exit code ${code}","messagePattern":"npm install failed with exit code (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/app/bundle.ts","lineNumber":294,"sourceCode":" * @param appDir Directory to check for node_modules (defaults to entry point directory)\n */\nexport async function ensureNodeModules(appDir?: string): Promise<void> {\n  const targetDir = appDir ?? process.cwd();\n  const nodeModulesPath = path.join(targetDir, \"node_modules\");\n\n  if (!fs.existsSync(nodeModulesPath)) {\n    log.info(colors.yellow(\"📦 node_modules not found, running npm install...\"));\n    const code = await new Promise<number>((resolve, reject) => {\n      const npmInstall = spawn(\"npm\", [\"install\"], {\n        cwd: targetDir,\n        stdio: \"inherit\",\n        shell: true,\n      });\n      npmInstall.on(\"close\", (code) => resolve(code ?? 0));\n      npmInstall.on(\"error\", reject);\n    });\n    if (code !== 0) {\n      throw new Error(`npm install failed with exit code ${code}`);\n    }\n    log.info(colors.green(\"✅ npm install completed\"));\n  }\n}\n\n/**\n * Creates an esbuild bundle for the app\n * @param options Bundle configuration options\n * @returns Bundle result containing JS and CSS blobs\n */\nexport async function createBundle(\n  options: BundleOptions = {}\n): Promise<BundleResult> {\n  // Native esbuild with a transparent esbuild-wasm fallback on host/binary\n  // version mismatch (see esbuild_loader.ts).\n  const esbuild = await getEsbuild();\n\n  // Detect frameworks to determine default entry point.","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/app/bundle.ts#L276-L312","documentation":"Thrown by ensureNodeModules when node_modules is absent from the app directory and the automatic 'npm install' spawned to bootstrap it exits non-zero. The command runs with cwd=appDir and shell:true, so the exit code reflects npm itself — typical causes are no/unreadable package.json in that directory, network or registry auth failures, unreachable private registry entries, or Node/npm version constraints in package.json that the host doesn't satisfy.","triggerScenarios":"Thrown at cli/src/commands/app/bundle.ts:294 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["cd into the app dir and run npm install manually to see the real npm error","Check package.json is valid and its registry/auth ( .npmrc ) entries reachable from this machine","Pre-install dependencies so node_modules already exists — the check is skipped entirely when the directory is present"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}