Fix cannot publish to npm error - npm ERR! Code E403
•2 min read•••• views
Recently when I published my last article on reduce()
, I faced this issue while publishing an update to my npm package @anilseervi/inspiratinal-quotes
.
@anilseervi/inspirational-quotes
is an npm package that I created for this blog site. It returns a random quote
(with it's author
) that you can see at the end of any article on this blog site.
While publishing a patch update to this package I noticed the following error message :
I wasn't able to find a proper solution to this problem.
This basically means that the version(defined in package.json
) you are pushing has already been pushed to the registry and you cannot publish over it.
Even if you don't see the version you are pushing in the NPM's UI, npm publish
would error out because you might have already pushed the same version to the registry but it was not published(public/private) due to some underlying errors.
Previously it was possible for one to un-publish a specific version and publish a new onto the same version. But now even if you un-publish a version, you won't be able to push a new update onto the same version. This doesn't mean that you should keep on bumping versions till you successfully publish your package.
Find the version you can publish
Here's what you can do to find what the version you can publish :
- Go to
https://registry.npmjs.org/(your_package_name)
- In the JSON file, check for the
time
property which is an object with key value pairs ofversion
and itsdate
published to the registry. - Find the latest version that is available on the registry.
- Publish the version that is not on the registry :D
It will be easier to find the version if you open the link in the FireFox browser.
Steps to publish the package
- Bump the version of your package using
npm version <version>
. - Login to npm registry using
npm login
. - Publish to npm registry using
npm publish
.