EISGIT occurs when npm detects a .git folder inside a node_modules dependency and refuses to modify it. Remove the .git folder from the problematic package or perform a clean reinstall.
npm encountered a git repository (.git folder) inside a node_modules dependency and refused to remove or replace it. npm has a long-standing safety policy of never deleting or overwriting git repositories to protect user code. This error typically occurs when a dependency was installed from a git source or contains a .git folder in its published tarball, and npm needs to update or remove that dependency.
Look at the error message to identify which package is causing the issue. The error will show a path like:
npm ERR! code EISGIT
npm ERR! path /path/to/node_modules/problematic-package
npm ERR! Appears to be a git repo or submodule.Note the exact package name for the next steps.
Navigate to the specific package's directory and remove its .git folder:
On macOS/Linux:
rm -rf node_modules/problematic-package/.gitOn Windows (PowerShell):
Remove-Item -Recurse -Force node_modules\problematic-package\.gitReplace problematic-package with the actual package name from the error message.
If multiple dependencies have .git folders, remove them all at once:
On macOS/Linux:
find node_modules -type d -name .git -exec rm -rf {} + 2>/dev/nullOn Windows (PowerShell):
Get-ChildItem -Path node_modules -Filter .git -Recurse -Force | Remove-Item -Recurse -ForceThis finds and removes all .git folders within node_modules without affecting your project's root .git folder.
Modify your package.json to use npm registry URLs instead of git sources:
Before (causes EISGIT):
{
"dependencies": {
"my-package": "git+ssh://[email protected]:user/repo.git#branch"
}
}After (uses npm registry):
{
"dependencies": {
"my-package": "^1.2.3"
}
}If removing individual .git folders doesn't resolve the issue, perform a clean reinstall:
# Remove entire node_modules directory
rm -rf node_modules
# Clear npm cache
npm cache clean --force
# Reinstall dependencies
npm installAfter resolving the issue, verify your installation is clean:
# Check if git folders still exist
find node_modules -type d -name .git
# Should return nothing if successfulThen reinstall to update your lockfile:
npm installFor package maintainers: The EISGIT error indicates your published npm package contains a .git folder, which should never be included. The .npmignore defaults should automatically exclude .git, but it may be explicitly included in your .npmignore with a negation pattern. Remove such negations. When publishing using git+ssh URLs as dependencies during development, use github: specifiers instead, which npm converts to registry URLs when publishing. For monorepo setups and workspaces, use npm workspaces with proper symbolic linking to avoid git repository conflicts.
npm notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm
npm error code E403 npm error 403 Forbidden - PUT https://registry.npmjs.org/<package>
How to fix 'E403 Forbidden' error in npm
npm ERR! code EUSAGE npm ERR! Usage error
How to fix "npm ERR! code EUSAGE" in Node.js projects
npm ERR! code E401 npm ERR! 401 Unauthorized
How to fix "E401 Unauthorized" in npm