Skip to content
Latchkey

npm publish "409 Conflict - cannot publish over previously published version" in CI

The version in package.json already exists on the registry, and npm never lets you overwrite a published version. The fix is to bump the version, not to force the publish.

What this error means

npm publish fails with "npm ERR! code E409" and "409 Conflict - PUT https://registry.npmjs.org/<pkg> - You cannot publish over the previously published versions: <version>."

npm
npm ERR! code E409
npm ERR! 409 Conflict - PUT https://registry.npmjs.org/my-pkg - You cannot publish over the previously published versions: 1.4.2.

Common causes

The version was never bumped before publishing

CI ran npm publish with a package.json version that is already live. npm treats published versions as immutable and rejects the re-publish.

A re-run of a release job that already succeeded

A retried or duplicated release workflow publishes the same tag twice; the first succeeded, the second hits 409.

How to fix it

Bump the version before publishing

  1. Increment the version in package.json (or run npm version patch).
  2. Commit and tag the new version as part of the release.
  3. Re-run the publish so it targets a version that does not exist yet.
Terminal
npm version patch -m "release %s"
npm publish

Make CI publish idempotent

Guard the publish step so a re-run does not try to republish an existing version. A common pattern checks the registry for the version first.

.github/workflows/release.yml
- run: |
    V=$(node -p "require('./package.json').version")
    if npm view "$(node -p "require('./package.json').name")@$V" version >/dev/null 2>&1; then
      echo "already published, skipping"
    else
      npm publish
    fi

How to prevent it

  • Only publish from a tagged release that always carries a fresh version.
  • Use npm version to bump and tag in one step.
  • Add a guard so re-running a release job skips an already-published version.

Frequently asked questions

What causes ""cannot publish over previously published version""?
CI ran npm publish with a package.json version that is already live. npm treats published versions as immutable and rejects the re-publish.
How do I fix "cannot publish over previously published version"?
Bump the version before publishing

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card