The HTTP 422 Unprocessable Entity error occurs when npm's request is syntactically correct but semantically invalid. This often indicates issues with package.json content or registry validation failures.
HTTP 422 means the server understands the request format but cannot process it due to semantic errors. In npm's context, this typically means your package.json or package content violates registry rules even though it's valid JSON. This differs from 400 Bad Request (malformed request) - with 422, the syntax is fine but the content doesn't make sense to the registry.
Check for issues:
# Validate package.json
npm pkg get
# Or use jsonlint
npx jsonlint package.json
# Check specific field
npm pkg get name versionEnsure name follows rules:
{
"name": "my-package"
}Rules:
- Lowercase only
- No spaces (use hyphens)
- Under 214 characters
- No leading dots or underscores
- No URL-unsafe characters
Version must be valid semver:
{
"version": "1.0.0"
}Valid formats: 1.0.0, 1.0.0-beta.1, 1.0.0-rc.1+build.123
Ensure all required fields exist:
{
"name": "package-name",
"version": "1.0.0",
"description": "What your package does",
"main": "index.js"
}Dependencies must be properly formatted:
{
"dependencies": {
"lodash": "^4.17.21",
"express": "~4.18.0"
}
}Valid specifiers: ^, ~, >=, exact versions, git URLs.
If present, repository must be valid:
{
"repository": {
"type": "git",
"url": "https://github.com/user/repo.git"
}
}Or shorthand: "repository": "github:user/repo"
npm registries may have different validation rules - what works on npmjs.com may fail on private registries. Use npm publish --dry-run to test without actually publishing. For scoped packages, ensure scope is properly configured. Some enterprise registries require additional metadata like license or author fields.
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error