The "Missing name" error occurs when your package.json lacks the required "name" field. The name is mandatory for npm to identify and work with your package.
The name field is one of only two required fields in package.json (along with version). It identifies your package and is used for installation, publishing, and referencing. Without a name, npm cannot identify your package, cannot install it from the registry, and cannot distinguish it from other packages.
Include name in package.json:
{
"name": "your-package-name",
"version": "1.0.0"
}Both name and version are required.
Let npm create valid package.json:
# Interactive
npm init
# Quick with defaults
npm init -yThis ensures all required fields exist.
The name might exist but be unparseable:
# Validate JSON
node -e "console.log(JSON.parse(require('fs').readFileSync('package.json')))"
# Pretty print to check
cat package.json | npx jsonIf accidentally deleted:
# See what changed
git diff package.json
# Restore
git checkout HEAD -- package.jsonIf name was lost in merge:
# Check for conflict markers
grep -n "<<<<<<" package.json
# Manually resolve or:
git checkout --theirs package.json
# Then verify and re-add your changesName selection tips:
- Descriptive but concise
- Lowercase with hyphens
- Check availability: npm view desired-name
- Consider scope for org: @myorg/package
For private packages not published to npm, name is still required but doesn't need to be unique. Private packages typically use scopes (@company/package). In monorepos, each package needs its own name. Workspaces reference packages by name, so consistency matters.
npm notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm
npm error code E403 npm error 403 Forbidden - PUT https://registry.npmjs.org/<package>
How to fix 'E403 Forbidden' error in npm
npm ERR! code EUSAGE npm ERR! Usage error
How to fix "npm ERR! code EUSAGE" in Node.js projects
npm ERR! code E401 npm ERR! 401 Unauthorized
How to fix "E401 Unauthorized" in npm