windmill-labs/windmill · error · Error
npm install failed with exit code ${code}
Error message
npm install failed with exit code ${code} What it means
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.
Source
Thrown at cli/src/commands/app/bundle.ts:294
* @param appDir Directory to check for node_modules (defaults to entry point directory)
*/
export async function ensureNodeModules(appDir?: string): Promise<void> {
const targetDir = appDir ?? process.cwd();
const nodeModulesPath = path.join(targetDir, "node_modules");
if (!fs.existsSync(nodeModulesPath)) {
log.info(colors.yellow("📦 node_modules not found, running npm install..."));
const code = await new Promise<number>((resolve, reject) => {
const npmInstall = spawn("npm", ["install"], {
cwd: targetDir,
stdio: "inherit",
shell: true,
});
npmInstall.on("close", (code) => resolve(code ?? 0));
npmInstall.on("error", reject);
});
if (code !== 0) {
throw new Error(`npm install failed with exit code ${code}`);
}
log.info(colors.green("✅ npm install completed"));
}
}
/**
* Creates an esbuild bundle for the app
* @param options Bundle configuration options
* @returns Bundle result containing JS and CSS blobs
*/
export async function createBundle(
options: BundleOptions = {}
): Promise<BundleResult> {
// Native esbuild with a transparent esbuild-wasm fallback on host/binary
// version mismatch (see esbuild_loader.ts).
const esbuild = await getEsbuild();
// Detect frameworks to determine default entry point.View on GitHub (pinned to e474e8803c)
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
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at cli/src/commands/app/bundle.ts:294 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/b5e63fdd185bd9aa.
Report an issue: GitHub.