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.
Fixes ENOENT
npm config get globalconfig
npm config get prefixnpm config get globalconfignpm config get prefixnpm ERR! code ENOENTnpm ERR! Error reading global configuration file
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.