How to fix npm ERR! code EISGIT npm ERR! path/to/package is a git submodule, use 'git' to remove it in npm

npmINTERMEDIATEHIGHUpdated Dec 5, 2025ยท 109 views

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
  1. Identify the problematic module
  2. Remove the .git folder from the problematic module
  3. Clean reinstall node_modules
  4. Update npm to version 6.10 or later
npm โ€” error
find node_modules -name ".git" -type d
npm ERR! code EISGIT
npm 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

  1. A dependency was installed from a GitHub URL that included the .git folder instead of using a tarball release
  2. You used npm link for local development and then attempted npm install, leaving .git metadata behind
  3. A package maintainer published their package with the .git directory included
  4. Cloning a monorepo or project with git submodules and running npm install without properly initializing submodules first
  5. npm cache contains .git folders from previous installations, causing conflicts on clean installs
  6. 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"

1Identify the problematic module

First, locate which module contains the .git folder. The error message should specify the path. If not clear, search manually:

bash
find node_modules -name ".git" -type d

This command will list all .git directories in your node_modules.

2Remove the .git folder from the problematic module

Once identified, remove the .git directory:

bash
rm -rf node_modules/some-package/.git

If you need to remove .git folders from all modules at once:

bash
find node_modules -name ".git" -type d -exec rm -rf {} +

On Windows PowerShell:

powershell
Get-ChildItem -Path node_modules -Filter .git -Recurse -Force | Remove-Item -Recurse -Force
3Clean reinstall node_modules

After removing the .git folders, perform a clean reinstall:

bash
rm -rf node_modules
rm package-lock.json
npm install

On Windows:

powershell
Remove-Item -Recurse -Force node_modules
Remove-Item package-lock.json
npm install
4Update npm to version 6.10 or later

The EISGIT error was particularly problematic in npm v6.9. Ensure you're running a newer version:

bash
npm --version

If you're running an older version, update npm:

bash
npm install -g npm@latest
5Use tarball URLs for GitHub dependencies

If you're installing directly from GitHub, use the tarball format instead of the git repository URL:

Avoid this:

json
{
  "dependencies": {
    "my-package": "github:username/repo#branch-name"
  }
}

Use this instead:

json
{
  "dependencies": {
    "my-package": "https://github.com/username/repo/tarball/main"
  }
}
6Add preinstall script to prevent recurrence

To prevent this issue from recurring, add a preinstall script to your package.json:

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