Replace native shell commands in package.json scripts with cross-platform alternatives to ensure build consistency across different operating systems. Native commands like `rm -rf` fail on Windows, breaking CI/CD pipelines that run on mixed environments.
Replace native shell commands in package.json scripts with cross-platform alternatives to ensure build consistency across different operating systems. Native commands like rm -rf
fail on Windows, breaking CI/CD pipelines that run on mixed environments.
Use tools like shx
or rimraf
instead of native shell commands:
{
"scripts": {
// โ Not cross-platform compatible
"clean": "rm -rf build",
"build": "rm -rf dist && rslib build && chmod +x dist/*.js",
// โ
Cross-platform compatible
"clean": "shx rm -rf build",
"build": "shx rm -rf dist && rslib build && shx chmod +x dist/*.js"
}
}
This ensures your build scripts work reliably in CI/CD environments regardless of the underlying operating system, preventing deployment failures due to platform-specific command incompatibilities.
Enter the URL of a public GitHub repository