Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

lerna publish stops with EUNCOMMIT although nothing was edited

Your error

lerna ERR! EUNCOMMIT Working tree has uncommitted changes, please commit or remove the following changes before continuing:1 more line it can show

Fix it fast

Most common cause, 1 of 3

npm install in CI rewrote package-lock.json

Use npm ci in the pipeline.

Fix
# .github/workflows/release.yml (install step)
- run: npm ci
- run: npx lerna publish --yes
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

lerna ERR! EUNCOMMIT means git describe --dirty found local changes when lerna version or lerna publish started. In CI the change usually comes from npm install rewriting package-lock.json, a build writing into tracked files, or an uncommitted version bump. Read the listed files, then use npm ci, untrack generated output or commit the bump. Applies to Lerna 10.

  • Applies to lerna 10.1.3, npm 12.2 (npm ci), Node.js 22, 24 and 26
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Add this step right before the lerna command in the CI job. Lerna prints the same short-status list after the error, so the paths tell you which cause applies: a lock file, build output, or package.json files.

Run this first
git status --porcelain
git diff --stat

Then find the line you see in this list and open its fix:

  1. 1npm install in CI rewrote package-lock.jsonThe list after EUNCOMMIT shows M package-lock.json (or the lock file of your package manager)
  2. 2A build step writes into files that Git tracksThe listed paths are build output such as packages/*/dist, lib or generated type files
  3. 3An earlier version bump was left uncommittedThe list shows several packages/*/package.json files (and maybe CHANGELOG.md) with new version numbers

What does the error look like?

  • lerna ERR! EUNCOMMIT Working tree has uncommitted changes, please commit or remove the following changes before continuing:
  • lerna ERR! EUNCOMMIT M package-lock.json

Cause 1 of 3

npm install in CI rewrote package-lock.json

You seeThe list after EUNCOMMIT shows M package-lock.json (or the lock file of your package manager)

Check

EUNCOMMIT with only the lock file listed means an install step changed it after checkout. npm install is allowed to update package-lock.json when it does not match package.json exactly, so the working tree is dirty by the time Lerna checks it.

Check
git diff --stat -- package-lock.json

Fix

Use npm ci in the pipeline. It needs an existing lock file, stops with an error when package.json and the lock disagree, and never writes to either file. If npm ci fails, run npm install locally and commit the updated lock file.

Fix
# .github/workflows/release.yml (install step)
- run: npm ci
- run: npx lerna publish --yes

Verify

git status --porcelain prints nothing before the lerna step, and the job moves past the working tree check.

Verify
test -z "$(git status --porcelain)" && echo clean

Confirmed by docs.npmjs.com

Did this fix it?

Cause 2 of 3

A build step writes into files that Git tracks

You seeThe listed paths are build output such as packages/*/dist, lib or generated type files

Check

When generated files are committed to the repository, every CI build changes them again and Lerna sees a dirty tree. A .gitignore rule alone does not help here: Git keeps tracking any file that is already in the index.

Check
git ls-files packages/*/dist | head

Fix

Remove the generated folders from the index and add them to .gitignore, then commit that change once. After that, builds create the files without touching anything Git tracks.

Fix
git rm -r --cached packages/*/dist
echo "packages/*/dist/" >> .gitignore
git add .gitignore
git commit -m "Stop tracking build output"

Verify

Run the build locally, then git status --porcelain. The dist folders no longer appear.

Verify
npm run build && git status --porcelain

Confirmed by git-scm.com

Did this fix it?

Cause 3 of 3

An earlier version bump was left uncommitted

You seeThe list shows several packages/*/package.json files (and maybe CHANGELOG.md) with new version numbers

Check

This happens when a job runs lerna version --no-git-tag-version, or a custom script edits versions, and then calls lerna publish. Without the git tag step Lerna leaves the package.json edits in the tree, and every publish mode (from-git, from-package, canary) refuses to continue while they are uncommitted.

Check
git diff -- packages/*/package.json | grep '"version"'

Fix

Let lerna version commit and tag the bump, or commit the edited files yourself before publishing. lerna publish from-package then publishes whatever versions are in the committed package.json files that the registry does not have yet.

Fix
git add packages/*/package.json
git commit -m "chore(release): publish"
npx lerna publish from-package --yes

Verify

lerna publish lists the packages it will release instead of stopping at EUNCOMMIT.

Verify
npx lerna publish from-package --yes

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Fail the CI job early with test -z "$(git status --porcelain)" after the install and build steps, so the step that dirties the tree is named in the log.
  • Use npm ci, not npm install, in every release workflow.
  • Keep build output out of Git and build it inside the release job, right before lerna publish.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: TaxiDex, Workforce.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.