How to fix npm ERR! code EISGIT npm ERR! Cannot remove: it is a git repo in npm
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.
Quick fix
Fixes EISGIT
npm ERR! code EISGIT
npm ERR! path /path/to/node_modules/problematic-package
npm ERR! Appears to be a git repo or submodule.- Identify the problematic package
- Remove the .git folder from the problematic package
- Remove all .git folders from node_modules (if multiple packages affected)
- Update package.json to use registry sources instead of git URLs
npm ERR! code EISGITnpm ERR! path /path/to/node_modules/problematic-packagenpm ERR! Appears to be a git repo or submodule.npm ERR! code EISGITnpm ERR! Cannot remove: it is a git repo
What this error means
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.
Typical symptoms
- npm install, npm update, or npm remove commands fail with 'code EISGIT' error
- Error message specifically mentions a path like 'node_modules/package-name' and says 'Appears to be a git repo or submodule'
- The issue only occurs after the problematic dependency is already installed in node_modules
- Clean installations work fine, but subsequent updates or reinstalls fail
- Error occurs with git+ssh or git+https dependencies that were resolved from a git URL
Common causes
- A dependency was installed from a git URL (git+ssh://, git+https://) instead of from npm registry, leaving a .git folder
- A package was published to npm with a .git folder accidentally included in the tarball
- A forked or local git repository was used as a dependency and contains a .git directory
- Multiple nested dependencies use git sources, creating .git folders at different levels in node_modules
- npm is attempting to update or reinstall a dependency that originally came from a git source
- Using symlinks or workspaces with git repositories as local dependencies
How to fix "npm ERR! code EISGIT npm ERR! Cannot remove: it is a git repo"
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://git@github.com: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 installAdvanced notes
For 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.
Frequently asked questions
- What does "EISGIT" mean?
- 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. git folder in its published tarball, and npm needs to update or remove that dependency.
- How do I fix "EISGIT"?
- 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.
- What causes "EISGIT"?
- A dependency was installed from a git URL (git+ssh://, git+https://) instead of from npm registry, leaving a .git folder A package was published to npm with a .git folder accidentally included in the tarball A forked or local git repository was used as a dependency and contains a .git directory
- Is the "EISGIT" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐npm Official Documentation
- ๐Docs: npm install(Official Docs)
- ๐ฌSO: npm git dependencies(Stack Overflow)
- ๐GitHub: npm repository(GitHub)