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 showFix it fast
Most common cause, 1 of 3npm install in CI rewrote package-lock.json
Use npm ci in the pipeline.
# .github/workflows/release.yml (install step)
- run: npm ci
- run: npx lerna publish --yesShort 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.
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.
git status --porcelain
git diff --statThen find the line you see in this list and open its fix:
- 1npm install in CI rewrote package-lock.json
The list after EUNCOMMIT shows M package-lock.json (or the lock file of your package manager) - 2A build step writes into files that Git tracks
The listed paths are build output such as packages/*/dist, lib or generated type files - 3An earlier version bump was left uncommitted
The 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.
git diff --stat -- package-lock.jsonFix
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.
# .github/workflows/release.yml (install step)
- run: npm ci
- run: npx lerna publish --yesVerify
git status --porcelain prints nothing before the lerna step, and the job moves past the working tree check.
test -z "$(git status --porcelain)" && echo cleanConfirmed by docs.npmjs.com
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.
git ls-files packages/*/dist | headFix
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.
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.
npm run build && git status --porcelainConfirmed by git-scm.com
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.
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.
git add packages/*/package.json
git commit -m "chore(release): publish"
npx lerna publish from-package --yesVerify
lerna publish lists the packages it will release instead of stopping at EUNCOMMIT.
npx lerna publish from-package --yesConfirmed by raw.githubusercontent.com
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.