The npm E406 error occurs when the npm registry server rejects your request due to incompatible Accept headers or misconfigured registry settings. This commonly happens with custom registries like Artifactory, Nexus, or private repositories.
HTTP 406 Not Acceptable is a client error response that indicates the server has received your request and the resource exists, but it cannot provide a response matching the content type your npm client is requesting. This typically happens when: 1. Your npm client sends an Accept header (like `application/vnd.npm.install-v1+json`) that the registry server doesn't understand or support. 2. The registry is a private repository (Artifactory, Nexus, etc.) that doesn't fully implement the npm registry specification. 3. The registry URL path is incorrect, preventing proper content type negotiation. The 406 error is essentially a communication mismatch between your npm client and the remote package server.
First, check which registry npm is currently configured to use:
npm config get registryIf you see a custom registry URL (not https://registry.npmjs.org/), that's likely where the issue is. Take note of the full URL for the next steps.
Ensure your registry URL follows the correct format:
For Artifactory:
npm config set registry https://artifacts.company.com/artifactory/api/npm/npm-remote/For Nexus 3:
npm config set registry https://nexus.company.com/repository/npm/For GitLab:
npm config set registry https://gitlab.company.com/api/v4/packages/npm/The key is including the /api/ or /repository/ path that points to the npm proxy/repository.
Clear any cached data that might be causing issues:
npm cache clean --forceThen attempt your install again:
npm installThis removes stale cache entries that might be interfering with content negotiation.
Temporarily switch to the official npm registry to isolate the problem:
npm config set registry https://registry.npmjs.org/
npm installIf this succeeds, the issue is with your custom registry configuration. If it fails, the problem is elsewhere (network, authentication, etc.). Once confirmed, switch back to your custom registry and check the URL format from Step 2.
For GitHub dependencies in package.json, use the git:// protocol instead of https://:
{
"dependencies": {
"my-package": "git://github.com/user/repo.git#branch-name"
}
}For private registries requiring authentication, ensure your .npmrc has the correct credentials:
npm login --registry=https://artifacts.company.com/artifactory/api/npm/npm-remote/Or add to .npmrc:
@myorg:registry=https://artifacts.company.com/artifactory/api/npm/npm-remote/
//artifacts.company.com/artifactory/api/npm/npm-remote/:_authToken=YOUR_TOKEN_HEREIf you're running Nexus 2.x with scoped packages (@myorg/package), upgrade to Nexus 3.x which has full npm scoped package support. For Artifactory users, ensure you're pointing to the correct repository path that proxies npmjs.org. Some older private registries may not correctly implement the npm Accept header specification (application/vnd.npm.install-v1+json); in these cases, contact your registry administrator for an update or configuration adjustment. Use npm install --verbose to see exact headers being sent and responses received.
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