This error occurs when npm cannot access or read the global configuration file, typically due to missing files, permission issues, or corrupted cache. It prevents npm commands from running and is usually fixable within minutes.
npm ERR! code ENOENT with 'Error reading global configuration file' means npm is looking for its global configuration file but cannot find it or doesn't have permission to read it. This can happen when the .npmrc file is deleted, corrupted, has wrong permissions, or when npm's global directories are misconfigured or missing.
Verify that npm can locate its configuration:
npm config get globalconfig
npm config get prefixIf either path doesn't exist or shows an error, this is your problem.
Corrupted cache is a common cause. Clear it with:
npm cache clean --forceTry running an npm command again.
The global .npmrc file may be corrupted. Safely remove it:
# On macOS/Linux
rm ~/.npmrc
# On Windows
del %APPDATA%\\.npmrcThen run any npm command to trigger recreation.
If you previously ran npm with sudo, file ownership may be mixed:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
sudo chown -R $(whoami) ~/.npm ~/.npmrcInstead of fixing permissions, configure npm to use a safe directory:
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'Add to your PATH in ~/.bashrc or ~/.zshrc:
export PATH=~/.npm-global/bin:$PATHFor the most reliable setup, use NVM or Volta:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install node
nvm use nodeVersion managers avoid system-wide permission problems entirely.
The npm configuration hierarchy loads multiple files in order: npm's built-in config → global config → user config → project config → command-line flags. ENOENT specifically means npm can't find the global config file it expects. Running npm config ls shows all active configuration from all sources. The root cause is often previous use of sudo npm install -g, which creates root-owned 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