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 127
Common 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 dist
Use a built-in delete instead
Recent Node has a portable recursive remove, removing the dependency for simple cleans.