The EINVALIDPACKAGENAME error occurs when your package name starts with a period (.) or underscore (_). Remove the leading character or use a scoped package name instead.
This error occurs when your package name begins with a dot (.) or underscore (_). npm prohibits these characters at the start of package names for several reasons: Names starting with dots are typically hidden files/directories on Unix systems (.gitignore, .env, .npmrc). If npm allowed packages with these names, they could conflict with configuration files or be accidentally hidden in file listings. Names starting with underscores were historically used for npm's internal purposes and are reserved for potential future use. The error often appears when system files like .DS_Store (macOS) or temporary directories are accidentally detected as packages during npm operations.
Remove the leading dot or underscore from your package.json:
// Invalid
{
"name": ".my-package"
}
// Valid
{
"name": "my-package"
}Or use a scoped name:
{
"name": "@myorg/my-package"
}Delete macOS system files from your project and node_modules:
# Remove from current directory and subdirectories
find . -name '.DS_Store' -type f -delete
# Remove from global npm directory
find /usr/local/lib/node_modules -name '.DS_Store' -type f -delete
# If using nvm
find ~/.nvm -name '.DS_Store' -type f -deleteAdd to .gitignore to prevent committing them:
.DS_StoreDelete npm's temporary directories that may have been left behind:
# Remove .npm-* directories from node_modules
rm -rf node_modules/.npm-*
# Remove from global directory
rm -rf /usr/local/lib/node_modules/.npm-*These directories are created during installation and should be cleaned up automatically, but sometimes remain after interrupted installs.
For Angular projects with __ngcc_entry_points__ errors:
# Remove the artifact
rm -rf node_modules/__ngcc_entry_points__.json
# Clear Angular cache
rm -rf .angular
# Reinstall
rm -rf node_modules package-lock.json
npm installIf the issue persists, do a full clean reinstall:
npm cache clean --force
rm -rf node_modules package-lock.json
npm installFor global packages:
npm cache clean --force
npm update -gScoped packages (@scope/name) technically allow the package name part to start with a dot or underscore after the slash, but this is discouraged and may cause issues with some tools.
The .DS_Store problem is particularly common when:
- macOS users commit node_modules to git
- Shared network drives are used for development
- node_modules is copied between systems
To permanently prevent .DS_Store creation in a directory:
defaults write com.apple.desktopservices DSDontWriteNetworkStores trueFor CI/CD pipelines, always use npm ci instead of npm install to ensure a clean, reproducible installation that won't pick up stray files.
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