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.
Fixes EPUBLISHCONFLICT
npm view your-package-name version
cat package.json | grep "version"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
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.
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.comIf 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 [email protected] '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.