How to fix npm ERR! code ELOOP npm ERR! ELOOP: too many symbolic links encountered in npm
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.
Quick fix
Fixes ELOOP
# 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 install- Clear npm cache and remove node_modules
- Verify no self-referencing symlinks exist
- Use --no-bin-links flag for network or problematic environments
- Configure npm to use local paths instead of network paths
# Clear npm cachenpm cache clean --force# Remove node_modules directoryrm -rf node_modules# On Windows PowerShellRemove-Item -Recurse -Force node_modules# Reinstall dependenciesnpm installnpm ERR! code ELOOPnpm ERR! ELOOP: too many symbolic links encountered
What this error means
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.
Typical symptoms
- npm install, npm update, or npm ci commands fail with 'ELOOP: too many symbolic links encountered' message
- Error includes a path reference showing where the problematic symlink was detected
- Issue occurs only when running npm commands, while the project directory itself is accessible
- Global npm operations (npm install -g) fail on network drives but local installations work
- Cordova, Ionic, or other tool-specific npm operations fail with ELOOP even though basic npm works
Common causes
- Self-referencing symlink in node_modules: A package folder contains a symlink that points to itself
- Network drive with excessive subfolders: User profile stored on network path with more than 2000+ nested subfolders
- Broken symlinks from previous installations that were not properly cleaned up
- Global npm cache on network path with deep folder hierarchies
- Circular dependency resolution: Package manager creates a symlink loop while resolving nested dependencies
- Workspace or monorepo symlink conflicts pointing back to parent directories
How to fix "npm ERR! code ELOOP npm ERR! ELOOP: too many symbolic links encountered"
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.
Advanced notes
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.
Frequently asked questions
- What does "ELOOP" mean?
- 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.
- How do I fix "ELOOP"?
- 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.
- What causes "ELOOP"?
- Self-referencing symlink in node_modules: A package folder contains a symlink that points to itself Network drive with excessive subfolders: User profile stored on network path with more than 2000+ nested subfolders Broken symlinks from previous installations that were not properly cleaned up
- Is the "ELOOP" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- ๐npm Official Documentation
- ๐Docs: Node.js Error Codes(Official Docs)
- ๐ฌSO: Symbolic links in npm(Stack Overflow)
- ๐GitHub: npm issues(GitHub)