This error occurs when npm cannot read or parse authentication credentials from your .npmrc file. Common causes include malformed syntax, expired tokens, unscoped auth credentials (npm v8+), or missing registry URLs.
npm EAUTHUNKNOWN indicates that npm tried to read authentication configuration from your .npmrc file but encountered a syntax error or invalid configuration format. This typically happens when authenticating with private npm registries. npm cannot parse the auth credentials, so it stops the installation process.
Locate and inspect your .npmrc file:
cat ~/.npmrcVerify the syntax matches this correct format:
registry=https://your-registry.com
//your-registry.com:_authToken=your-token-hereIf using npm v8 or newer, all auth values must be scoped:
Before (won't work in npm v8+):
_authToken=your-token-hereAfter (npm v8+):
//private-registry.com:_authToken=your-token-herenpm v8+ warns about unscoped auth. Remove any global auth settings:
npm config delete _auth
npm config delete _authToken
npm config delete always-authThe token may be expired. For npm:
npm logout
npm loginFor Azure DevOps:
npx vsts-npm-auth -config .npmrcEnsure .npmrc and package-lock.json use matching protocols:
grep -i 'registry' ~/.npmrc
grep -i 'registry' package-lock.json | head -5Both should use the same protocol (http vs https).
Once fixed, perform a clean install:
rm -rf package-lock.json node_modules
npm cache clean --force
npm installThe EAUTHUNKNOWN error became more common after npm v8 introduced stricter validation of .npmrc auth fields. Previous versions allowed global _auth values, but npm v8+ requires scoping to specific registries using the //registry-url:field=value format. This change improves security but breaks existing .npmrc files.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
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 EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error