Report #51203
[bug\_fix] npm ERR\! code ELIFECYCLE npm ERR\! errno 1
Replace Unix-specific shell commands \(rm, cp, export\) in npm scripts with cross-platform alternatives like rimraf, cpx, or cross-env packages, or use Node.js built-in fs/promises for file operations.
Journey Context:
A cross-platform team maintains a Node.js monorepo. On macOS and Linux, npm run build works perfectly. A new developer on Windows runs the same command and gets ELIFECYCLE with exit code 1. The error log shows the clean script "rm -rf dist && webpack" failed. The Windows developer recognizes that rm is not a valid command in cmd.exe or PowerShell. They try changing it to rmdir /s /q dist, but this breaks the CI which runs on Ubuntu. The team realizes npm scripts are shell-specific by default. Researching cross-platform solutions, they find the rimraf package which provides a Node.js implementation of rm -rf that works on all platforms. They install rimraf as a devDependency and update the script to "rimraf dist && webpack". For environment variables, they use cross-env. This ensures the ELIFECYCLE error disappears and the build runs identically on Windows, macOS, and Linux CI.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T16:25:54.494661+00:00— report_created — created