The EMLINK error occurs when npm encounters too many hard links or symlinks during installation, typically caused by filesystem limits, self-referencing symlinks, or link configuration issues. Clear your cache, check for broken symlinks, and reconfigure npm's linking behavior to resolve the problem.
EMLINK stands for "Error Maximum LINK" and is a filesystem-level error indicating that the system has hit its maximum limit for hard links or symbolic links. During npm install, npm creates symlinks to bin files and dependencies in node_modules. When the filesystem encounters too many of these links—either from accumulated installations, self-referencing symlinks, or corrupted link chains—npm cannot complete the installation. This is distinct from ELOOP (too many symbolic link levels), though both involve linking issues. The error can also occur when npm tries to create subdirectories and the system refuses due to existing link counts exceeding the filesystem's limit.
Start with a clean slate by removing cached data and installed modules. This eliminates corruption from previous failed installs.
npm cache clean --force
rm -rf node_modules
rm -f package-lock.jsonOn Windows, use these commands instead:
npm cache clean --force
rmdir /s /q node_modules
del package-lock.jsonBefore reinstalling, verify there are no broken symlinks. Look for symlinks that point to themselves or create circular references.
On macOS/Linux:
find . -type l -exec sh -c 'file "$1" | grep -q "broken" && echo "$1"' _ {} \;This shows all broken symlinks. Remove any found in your project directory:
rm -f path/to/broken/symlinkOn Windows, use a file explorer tool or PowerShell to inspect junction/symlink targets.
Network filesystems and shared storage often have lower hard link limits. Configure npm to copy dependencies instead of symlinking them.
Create or edit .npmrc in your project root:
install-links=falseOr run npm install with the flag:
npm install --install-links=falseNote: This applies to npm v9+. For older versions, use --no-bin-links (though this only affects binary links, not all symlinks).
Now that you've cleaned up, reinstall with a verbose flag to see exactly where the error occurs if it happens again.
npm install --verboseIf the error persists, the output will show the exact package/path causing the issue. Note this for the next step.
If you use local file references in package.json (e.g., "dependency": "file:../local-package"), these create symlinks that can hit limits. Convert them to copies instead:
In package.json, change:
"mypackage": "file:../mypackage"To use npm pack instead:
cd ../mypackage
npm pack
cd ../myapp
npm install ../mypackage/mypackage-1.0.0.tgzThis creates a tarball copy instead of a symlink, avoiding link limit issues.
The EMLINK error is filesystem-specific and behavior varies by OS and storage type. On Linux systems with ext4, the hard link limit is typically 65,000 per inode. Network File System (NFS) mounts and Windows SMB shares often have stricter limits. If you're on a network drive and repeatedly encounter EMLINK, permanently configure install-links=false in your global .npmrc (~/.npmrc on Unix, %APPDATA%\.npmrc on Windows). For monorepo workspaces, consider using npm workspaces (npm v7+) or yarn/pnpm, which handle symlinks more intelligently. If the error occurs only in CI/CD pipelines, check if the runner's filesystem or Docker image has different link limit configurations than your local machine.
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