Node.js "rimraf: command not found" in CI
A clean script calls rimraf to delete build output, but the binary is missing in CI. As a devDependency, it disappears under a production install and the script exits 127.
What this error means
A clean or prebuild script using rimraf dist fails with rimraf: command not found. The same script works locally where dev deps are installed.
node
> clean
> rimraf dist
sh: rimraf: command not found
npm ERR! code 127Common causes
rimraf is a missing devDependency
rimraf is dev-only. With dev deps pruned or uninstalled, the binary is absent and the clean step fails.
How to fix it
Install rimraf or use it via npx
Add rimraf to devDependencies, or invoke it through npx so it resolves from the registry if absent.
Terminal
npm install -D rimraf
# or call without a local install
npx rimraf distUse a built-in delete instead
Recent Node has a portable recursive remove, removing the dependency for simple cleans.
package.json
node --eval "fs.rmSync('dist', { recursive: true, force: true })"How to prevent it
- Keep dev deps installed for build/clean jobs.
- Prefer the built-in recursive remove for simple cleans.
- Declare every CLI used by scripts in package.json.
Related guides
Node.js "cross-env: command not found" in CIFix "cross-env: command not found" in CI - the cross-env binary is missing because devDependencies were prune…
npm Script Exit 127 "command not found" - Fix Missing Tool in CIFix npm scripts failing with exit code 127 "command not found" in CI - a binary the script calls is not insta…
npm Script "command not found" (PATH) in CI - Fix Missing BinariesFix "command not found" inside an npm script in CI by installing the tool as a devDependency or ensuring node…