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:
- shell: process.platform === 'win32' (platform-conditional — chosen)
- shell: true (all platforms — works but loses signal handling on Unix)
- Replace npx with node_modules/.bin/tsc directly
- 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
tools/scripts/build/build-angular-library.js
🔗 Related
- Decision ID:
dev_1772055350372_bkcucs7 - Session: 142
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation