How to fix npm ERR! code EPUBLISHCONFLICT npm ERR! Cannot publish over existing version. Bump the version in package.json and try again in npm
EPUBLISHCONFLICT occurs when you attempt to publish a package version that already exists in the npm registry. Bump your version number using npm version patch/minor/major and publish again.
Quick fix
Fixes EPUBLISHCONFLICT
npm view your-package-name version
cat package.json | grep "version"- Verify the current package version
- Increment the version number
- Ensure you are authenticated and publishing to the correct registry
- Update npm and Node.js to the latest versions
npm view your-package-name versioncat package.json | grep "version"npm ERR! code EPUBLISHCONFLICTnpm ERR! Cannot publish over existing version. Bump the version in package.json and try again
What this error means
This error occurs when you attempt to publish a package version to npm that already exists in the registry. npm enforces strict version immutability—once a specific version number is published, that exact name-and-version combination can never be reused. This is a deliberate design choice to ensure package integrity and prevent accidentally overwriting previously released code. The registry rejects the publish attempt to protect users from potential confusion or security issues.
Typical symptoms
- npm publish command fails with 'EPUBLISHCONFLICT' error code
- Error message states 'Cannot publish over existing version'
- You recently unpublished a version and cannot republish it
- Publishing works for new versions but fails for the current package.json version
- CI/CD pipeline fails at the npm publish step without version changes
Common causes
- The version in package.json matches a previously published release to the npm registry
- You unpublished a version and are attempting to publish the same version number again (unpublished versions cannot be reused)
- Outdated npm client version causing race conditions or version detection issues
- Publishing to a private registry that proxies to npmjs and conflicts with existing public packages
- Manual version changes to package.json that match an already-published version number
- Network or server issues during a previous publish attempt left the registry in an inconsistent state
How to fix "npm ERR! code EPUBLISHCONFLICT npm ERR! Cannot publish over existing version. Bump the version in package.json and try again"
Check what version is currently published to npm and compare it with your package.json:
npm view your-package-name version
cat package.json | grep "version"If the published version matches your local package.json version, this confirms the conflict.
Update your package.json to a new, unique version. Use npm's built-in version commands:
# For bug fixes (1.0.0 -> 1.0.1)
npm version patch
# For new features (1.0.0 -> 1.1.0)
npm version minor
# For breaking changes (1.0.0 -> 2.0.0)
npm version majorThese commands automatically update package.json and create a git tag.
Confirm your npm authentication and target registry:
# Check your current authentication
npm whoami
# Verify the registry URL
npm config get registry
# View your account's published packages
npm owner ls your-package-nameEnsure you're logged in and publishing to the correct registry.
Outdated npm versions can experience race conditions and version detection issues:
# Update npm globally to latest
npm install npm@latest -g
# Check npm version
npm --versionAfter incrementing the version, publish your package:
# Standard publish to public registry
npm publish
# If publishing a pre-release (beta, alpha, etc.)
npm publish --tag beta
# For scoped packages, ensure public access (if desired)
npm publish --access publicVerify the publish succeeded:
npm view your-package-name versionsIf using a private registry like Verdaccio that proxies to npmjs, adjust the configuration:
# Edit config.yaml
packages:
'@scope/*':
access: $authenticated
publish: $authenticatedOr explicitly specify the registry when publishing:
npm publish --registry https://your-verdaccio-instance.comAdvanced notes
If you accidentally published the wrong code to a version, you have limited options: npm supports unpublishing within 72 hours of publication, but unpublished versions cannot be republished with the same version number. The recommended approach is to publish a new patch version with the corrections. For critical security issues, publish a newer patch immediately and deprecate the old version with npm deprecate your-package@1.0.0 'This version has security issues, please upgrade'. When using CI/CD pipelines, ensure the version bump happens before npm publish, and consider using tools like semantic-release to automate versioning.
Frequently asked questions
- What does "EPUBLISHCONFLICT" mean?
- This error occurs when you attempt to publish a package version to npm that already exists in the registry. npm enforces strict version immutability—once a specific version number is published, that exact name-and-version combination can never be reused. This is a deliberate design choice to ensure package integrity and prevent accidentally overwriting previously released code.
- How do I fix "EPUBLISHCONFLICT"?
- EPUBLISHCONFLICT occurs when you attempt to publish a package version that already exists in the npm registry. Bump your version number using npm version patch/minor/major and publish again.
- What causes "EPUBLISHCONFLICT"?
- The version in package.json matches a previously published release to the npm registry You unpublished a version and are attempting to publish the same version number again (unpublished versions cannot be reused) Outdated npm client version causing race conditions or version detection issues
- Is the "EPUBLISHCONFLICT" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 📖Docs: npm publish(Official Docs)
- 💬SO: npm publish conflicts(Stack Overflow)
- 🐙GitHub: npm repository(GitHub)