The ENOENT .npmrc error occurs when npm expects a configuration file that doesn't exist. This is usually not critical unless the file is referenced explicitly.
.npmrc files contain npm configuration. They can exist at multiple levels: project (./npmrc), user (~/.npmrc), and global. The ENOENT error for .npmrc usually means npm was told to look for one that doesn't exist. This often happens when environment variables or other configuration point to a non-existent .npmrc file, or when a project expects .npmrc but it wasn't committed or created.
Determine if .npmrc is required:
# Check if your project needs one
ls -la .npmrc
# Check npm config sources
npm config list --json | jqCreate if needed:
# Empty file is valid
touch .npmrc
# Or with content
echo "registry=https://registry.npmjs.org/" > .npmrcLook for misconfigured paths:
echo $NPM_CONFIG_USERCONFIG
echo $NPM_CONFIG_GLOBALCONFIG
# Unset if pointing to wrong place
unset NPM_CONFIG_USERCONFIGSet up authentication:
# .npmrc for private registry
registry=https://npm.company.com/
//npm.company.com/:_authToken=${NPM_TOKEN}
# Keep out of git!
echo ".npmrc" >> .gitignoreDocument required config:
# .npmrc.example (commit this)
registry=https://npm.company.com/
# README instructions
# Copy .npmrc.example to .npmrc and add tokenSet up config in CI:
# GitHub Actions
steps:
- name: Create .npmrc
run: |
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
env:
NPM_TOKEN: \${{ secrets.NPM_TOKEN }}Multiple .npmrc files are merged with project > user > global precedence. Never commit auth tokens to .npmrc - use environment variables. In monorepos, .npmrc at root applies to all workspaces. Some CI systems have built-in npm authentication that doesn't require .npmrc. Use npm config ls -l to see all config sources.
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"