How to fix npm ERR! code EISGIT npm ERR! path/to/package is a git submodule, use 'git' to remove it in npm
This EISGIT error occurs when npm detects a git submodule in your dependencies. Use git commands to properly remove the submodule, or remove the .git folder from the problematic package.
Quick fix
Fixes EISGIT
find node_modules -name ".git" -type d- Identify the problematic module
- Remove the .git folder from the problematic module
- Clean reinstall node_modules
- Update npm to version 6.10 or later
find node_modules -name ".git" -type dnpm ERR! code EISGITnpm ERR! path/to/package is a git submodule, use 'git' to remove it
What this error means
The npm EISGIT error occurs when npm detects a .git folder or file inside a module in your node_modules directory and refuses to modify or remove it to protect git repository data. This specific variant indicates npm detected a git submodule configuration. This typically happens when a dependency contains embedded git metadata, either because it was installed from a git repository with its .git folder intact, or because it's configured as a git submodule. npm's safety mechanism prevents accidental deletion of git repositories.
Typical symptoms
- npm install or npm update fails with error code EISGIT
- Error message states 'Appears to be a git repo or submodule' for a specific package path
- npm refuses to remove or overwrite a problematic module directory
- Installation works on some systems but fails on others (due to cached node_modules)
- Deployment fails on CI/CD platforms due to .git remnants
Common causes
- A dependency was installed from a GitHub URL that included the .git folder instead of using a tarball release
- You used npm link for local development and then attempted npm install, leaving .git metadata behind
- A package maintainer published their package with the .git directory included
- Cloning a monorepo or project with git submodules and running npm install without properly initializing submodules first
- npm cache contains .git folders from previous installations, causing conflicts on clean installs
- A workspace or private dependency contains embedded git history
How to fix "npm ERR! code EISGIT npm ERR! path/to/package is a git submodule, use 'git' to remove it"
First, locate which module contains the .git folder. The error message should specify the path. If not clear, search manually:
find node_modules -name ".git" -type dThis command will list all .git directories in your node_modules.
Once identified, remove the .git directory:
rm -rf node_modules/some-package/.gitIf you need to remove .git folders from all modules at once:
find node_modules -name ".git" -type d -exec rm -rf {} +On Windows PowerShell:
Get-ChildItem -Path node_modules -Filter .git -Recurse -Force | Remove-Item -Recurse -ForceAfter removing the .git folders, perform a clean reinstall:
rm -rf node_modules
rm package-lock.json
npm installOn Windows:
Remove-Item -Recurse -Force node_modules
Remove-Item package-lock.json
npm installThe EISGIT error was particularly problematic in npm v6.9. Ensure you're running a newer version:
npm --versionIf you're running an older version, update npm:
npm install -g npm@latestIf you're installing directly from GitHub, use the tarball format instead of the git repository URL:
Avoid this:
{
"dependencies": {
"my-package": "github:username/repo#branch-name"
}
}Use this instead:
{
"dependencies": {
"my-package": "https://github.com/username/repo/tarball/main"
}
}To prevent this issue from recurring, add a preinstall script to your package.json:
{
"scripts": {
"preinstall": "find node_modules -name .git -type d -prune -exec rm -rf {} + 2>/dev/null || true"
}
}Advanced notes
For monorepo or workspace setups, this error often indicates improper git submodule configuration. If your project uses git submodules, ensure you properly initialize them before running npm install: git submodule update --init --recursive. For CI/CD platforms like Heroku, disable npm cache with heroku config:set NODE_MODULES_CACHE=false if the error persists. Some teams also use .gitattributes with export-ignore directive to exclude git metadata from distribution archives.
Frequently asked questions
- What does "EISGIT" mean?
- git folder or file inside a module in your node_modules directory and refuses to modify or remove it to protect git repository data. This specific variant indicates npm detected a git submodule configuration. git folder intact, or because it's configured as a git submodule.
- How do I fix "EISGIT"?
- This EISGIT error occurs when npm detects a git submodule in your dependencies. Use git commands to properly remove the submodule, or remove the .git folder from the problematic package.
- What causes "EISGIT"?
- A dependency was installed from a GitHub URL that included the .git folder instead of using a tarball release You used npm link for local development and then attempted npm install, leaving .git metadata behind A package maintainer published their package with the .git directory included
- Is the "EISGIT" 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: Git submodules in npm(Official Docs)
- ๐ฌSO: Git submodules with npm(Stack Overflow)
- ๐