Skip to content
Latchkey

semantic-release "@semantic-release/exec" command failed in CI

The @semantic-release/exec plugin runs shell commands you define at each lifecycle step. When one of those commands exits non-zero, exec fails the release and reports which command and step failed. The fix is in your command, not semantic-release itself.

What this error means

The run fails with "Failed step \"prepare\" of plugin \"@semantic-release/exec\"" and the non-zero exit output of your configured command.

semantic-release
[semantic-release] > Failed step "prepare" of plugin "@semantic-release/exec"
Command failed with exit code 1: ./scripts/build.sh 1.4.0
./scripts/build.sh: line 3: tsc: command not found

Common causes

The configured command itself fails

A build or version script referenced in prepareCmd/publishCmd exits non-zero because of a missing tool or a real error.

A tool used by the command is not on PATH

The command calls a binary (tsc, jq) not installed on the runner, so it fails before doing its work.

How to fix it

Reproduce and fix the command

  1. Run the exact prepareCmd/publishCmd locally with the version variable.
  2. Install any missing tools the command needs earlier in the job.
  3. Re-run once the command exits zero on its own.
.releaserc plugins
["@semantic-release/exec", {
  "prepareCmd": "npm run build -- --version ${nextRelease.version}"
}]

Ensure command dependencies are installed

Install and expose the tools your exec commands call before the release step.

.github/workflows/release.yml
- run: npm ci
- run: npx semantic-release

How to prevent it

  • Test exec commands locally with the nextRelease variables.
  • Install every tool the command needs before semantic-release runs.
  • Keep exec commands small and independently runnable.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →