EISDIR occurs when npm attempts to perform a file operation on a path that is actually a directory. This typically happens due to corrupted node_modules or accidentally creating directories with file names.
EISDIR stands for 'Error, Is Directory' and occurs when npm attempts to perform a file operation (like reading or writing) on a path that is actually a directory instead of a file. This commonly happens during npm install, when npm tries to read a configuration file or access a package file, but encounters a directory at that path instead. The error prevents npm from continuing because it cannot complete the file-level operation on a directory object. This is usually caused by corrupted installations or accidental directory creation with file names.
Run the following command to force clean your npm cache, then verify it was successful:
npm cache clean --force
npm cache verifyThis removes any corrupted cache entries that might be causing the EISDIR error.
Remove the potentially corrupted node_modules and lock file, then perform a fresh install:
rm -rf node_modules package-lock.json
npm installOn Windows, you may need to use:
rmdir /s /q node_modules
del package-lock.json
npm installVerify that you don't have directories created with file names:
# On macOS/Linux - should show files, not directories
ls -la .gitignore .env package.json .npmrc 2>/dev/nullIf any of these are directories instead of files, remove them:
rm -rf .gitignore .env package.json .npmrc
# Recreate as files with proper content
echo "" > .gitignoreReset npm directory ownership to your user instead of root:
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules
sudo chown -R $(whoami) ~/.cache/npmAlternatively, configure npm to use a local prefix:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATHSome versions of npm had known EISDIR issues. Update to a stable version:
npm install -g npm@latest
npm --versionOr update Node.js using a version manager:
# Using nvm (macOS/Linux)
nvm install node
nvm use nodeOn Windows systems with monorepos, EISDIR can occur when npm attempts to create symlinks in node_modules/.bin but encounters permission issues or conflicting directories. If you're on Windows, try enabling developer mode or running npm with administrator privileges. Additionally, special characters (like #) in folder paths can trigger this error on Windows; rename the parent directory to use only alphanumeric characters and hyphens.
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