The EINVALIDPACKAGENAME error for capital letters occurs because npm requires all package names to be lowercase. Convert your package name to lowercase, using hyphens to separate words.
This error occurs when your package name contains uppercase letters. npm requires all package names to be lowercase—no exceptions for new packages. This rule was introduced to prevent confusion on case-insensitive file systems (like Windows and macOS default). If both 'MyPackage' and 'mypackage' were allowed, they'd conflict on these systems. It also prevents typosquatting attacks where 'Lodash' could be registered to catch typos of 'lodash'. Some old packages in the registry still have uppercase letters (they were grandfathered in), but you cannot publish new packages with capitals.
Change your package name to lowercase, using hyphens to separate words:
// Invalid
{
"name": "MyAwesomePackage"
}
// Valid
{
"name": "my-awesome-package"
}Common conversions:
- MyPackage → my-package
- myPackage → my-package
- MYPACKAGE → mypackage
After renaming, update references throughout your project:
# Find files that might reference the old name
grep -r "MyPackage" --include="*.js" --include="*.ts" --include="*.json"Update:
- Import/require statements
- README.md
- Documentation
- CI/CD configurations
npm package naming best practices:
// Good: lowercase with hyphens
"name": "react-router-dom"
"name": "lodash-es"
"name": "date-fns"
// Also valid: underscores (less common)
"name": "socket_io"
// Valid: scoped with lowercase
"name": "@angular/core"Avoid underscores at the start (they're reserved).
Check your name before publishing:
npx validate-npm-package-name "my-package-name"Output shows if the name is valid and what issues exist if not.
If you're renaming an existing package directory:
# On case-insensitive systems (macOS, Windows), use a temp name
mv MyPackage temp-my-package
mv temp-my-package my-packageDirect mv MyPackage my-package won't work on case-insensitive file systems because they see it as the same name.
The lowercase requirement was introduced around npm v1.3. Existing packages with uppercase letters were grandfathered in and still work—they just can't publish new versions with uppercase names.
If you absolutely need a mixed-case display name, you can use the displayName field in package.json for documentation purposes:
{
"name": "mypackage",
"displayName": "MyPackage"
}Note that displayName isn't officially standardized by npm but is used by some tools like VS Code extensions.
For organizations transitioning from private registries that allowed uppercase, you may need to rename packages when publishing to npm. Create aliases or wrapper packages if backwards compatibility is needed.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
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 EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"