ELOOP occurs when npm encounters a circular or excessively deep chain of symbolic links during package operations. Resolve it by removing node_modules, clearing cache, or using --no-bin-links flag.
The ELOOP error occurs when npm encounters a circular or excessively deep chain of symbolic links during package installation or operations. This happens when the filesystem traversal encounters the same directory multiple times through symlinks, creating an infinite loop. The error is triggered when a symlink points to itself (directly or indirectly) or when traversing network paths with thousands of subfolders exceeds the operating system's symlink depth limit of approximately 2000 levels.
Start fresh by clearing the npm cache and deleting the entire node_modules directory:
# Clear npm cache
npm cache clean --force
# Remove node_modules directory
rm -rf node_modules
# On Windows PowerShell
Remove-Item -Recurse -Force node_modules
# Reinstall dependencies
npm installCheck the node_modules directory for symlinks that point to themselves:
# List all symlinks in node_modules
find node_modules -type l -exec ls -la {} \;
# On Windows PowerShell
Get-ChildItem -Path node_modules -Recurse -Attributes ReparsePointIf you find a symlink pointing to itself, delete it manually and run npm install again.
If you're on a network drive or experiencing persistent issues, try installing without creating binary symlinks:
npm install --no-bin-links
# Or for global packages
npm install -g package-name --no-bin-linksThis prevents npm from creating symlinks that may cause ELOOP errors on network filesystems.
If using npm on a network drive, configure npm cache and global prefix to use local filesystem paths:
# Set local cache directory
npm config set cache ~/.npm-cache
# Set local global prefix
npm config set prefix ~/.npm-global
# On Windows, use local paths
npm config set cache C:\Users\YourUsername\AppData\Roaming\npm-cache --global
# Verify configuration
npm config listIf the issue persists, the lock file may be referencing broken symlinks:
# Remove lock file and node_modules
rm -rf node_modules package-lock.json
# Clean cache again
npm cache clean --force
# Fresh install
npm installIf npm continues to fail, consider switching to pnpm which has better symlink handling:
# Install pnpm globally
npm install -g pnpm
# Remove node_modules
rm -rf node_modules
# Install with pnpm
pnpm installpnpm resolves packages to their real location rather than following symlink chains.
The ELOOP error is particularly common in enterprise environments where user home directories are network-mounted. The operating system's symlink resolution has a depth limit (usually around 2000 levels), and traversing deeply nested network paths can exceed this. On Windows, the issue may be exacerbated by case-sensitivity differences and how NTFS handles junction points versus true symlinks. In CI/CD environments, consider using npm ci which respects lock files and may be less prone to symlink issues.
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