What This Error Means
npm received HTTP 422 because the publish payload was semantically invalid, such as bad metadata, malformed tarball data, or invalid package state.
Read this as a precise clue about which part of the workflow broke first. Once you know the failing layer, the fix path gets much shorter.
How to Fix It
Check which registry npm is using:npm config get registry
If the package is scoped, verify scope registry mapping in .npmrc (example: @your-scope:registry=...).
Validate package.json fields (name, version, files) and ensure the package packs correctly: npm pack.
Check for invalid semver or forbidden characters in the package name.
Why It Happens
Usually this comes down to the version is already published (most common), the package metadata is invalid or violates registry policy, or you are publishing to the wrong registry or scope.
Verify the Fix
Run npm view <pkg>@<version> and confirm the new version exists after publish, and re-run publish and confirm the registry accepts it.
Manual validation checklist
Preview what will be published with npm pack --dry-run (or npm pack and inspect the tarball), and confirm effective registry with npm config get registry.
Examples
npm ERR! code E422
npm ERR! 422 Unprocessable Entity - PUT https://registry.npmjs.org/npm-sync - Unprocessable Entity How npm surfaces this error
Registries treat versions as immutable. A version conflict is an expected protection. Invalid package metadata causes publish validation errors.
Prevent It From Coming Back
To prevent this, automate version bumps as part of release workflow, keep registry routing explicit for scoped packages, and validate package contents with npm pack before publishing.
Docs and source code
github.com/npm/cli/blob/417daa72b09c5129e7390cd12743ef31bf3ddb83/lib/utils/ping.js
This is a registry request path. Many resolution/publish errors happen while fetching or publishing package metadata to the registry. - GitHub
// used by the ping and doctor commands
const npmFetch = require('npm-registry-fetch')
module.exports = async (flatOptions) => {
const res = await npmFetch('/-/ping', { ...flatOptions, cache: false })
return res.json().catch(() => ({}))
}