Bugfix: How to fix 'spawn npx ENOENT' error when build-angular-libra...

Documentation for Sessions

🐛 Bugfix: How to fix 'spawn npx ENOENT' error when build-angular-libra...

Date: 2026-02-25
Time: 21:35:50 UTC
Session: gspace1-142.5
Agent: angular
Confidence: 96%
Status: ✅ Documented


📋 Decision Context

Question:

How to fix 'spawn npx ENOENT' error when build-angular-library.js runs on Windows CI?

Task: Fix Vitto Desktop CI/CD release workflow


🎯 Decision Made

Chosen:

Add shell: process.platform === 'win32' to the spawn() options in the runCommand() function. This tells Node.js to use cmd.exe on Windows, which can resolve npx.cmd wrappers.

Options Considered:

  1. shell: process.platform === 'win32' (platform-conditional — chosen)
  2. shell: true (all platforms — works but loses signal handling on Unix)
  3. Replace npx with node_modules/.bin/tsc directly
  4. Use cross-spawn npm package

💭 Reasoning

Node.js child_process.spawn() without shell:true looks for a literal executable named 'npx'. On Windows, npx is installed as npx.cmd (a batch file wrapper). Without shell:true, spawn() returns ENOENT because there's no 'npx' binary. Using shell:true on Windows only (not all platforms) lets cmd.exe resolve the .cmd extension while keeping direct execution on Unix for better signal handling. This affected ALL libraries using the custom builder that called npx for tsc, sass, and api-extractor.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation