How to fix npm ERR! code EISGIT npm ERR! Cannot remove: it is a git repo in npm

npmBEGINNERMEDIUMUpdated Dec 5, 2025ยท 136 views

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.
  1. Identify the problematic package
  2. Remove the .git folder from the problematic package
  3. Remove all .git folders from node_modules (if multiple packages affected)
  4. Update package.json to use registry sources instead of git URLs
npm โ€” error
npm ERR! code EISGIT
npm ERR! path /path/to/node_modules/problematic-package
npm ERR! Appears to be a git repo or submodule.
npm ERR! code EISGIT
npm 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

  1. A dependency was installed from a git URL (git+ssh://, git+https://) instead of from npm registry, leaving a .git folder
  2. A package was published to npm with a .git folder accidentally included in the tarball
  3. A forked or local git repository was used as a dependency and contains a .git directory
  4. Multiple nested dependencies use git sources, creating .git folders at different levels in node_modules
  5. npm is attempting to update or reinstall a dependency that originally came from a git source
  6. 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"

1Identify the problematic package

Look at the error message to identify which package is causing the issue. The error will show a path like:

bash
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.

2Remove the .git folder from the problematic package

Navigate to the specific package's directory and remove its .git folder:

On macOS/Linux:

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

On Windows (PowerShell):

powershell
Remove-Item -Recurse -Force node_modules\problematic-package\.git

Replace problematic-package with the actual package name from the error message.

3Remove all .git folders from node_modules (if multiple packages affected)

If multiple dependencies have .git folders, remove them all at once:

On macOS/Linux:

bash
find node_modules -type d -name .git -exec rm -rf {} + 2>/dev/null

On Windows (PowerShell):

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

This finds and removes all .git folders within node_modules without affecting your project's root .git folder.

4Update package.json to use registry sources instead of git URLs

Modify your package.json to use npm registry URLs instead of git sources:

Before (causes EISGIT):

json
{
  "dependencies": {
    "my-package": "git+ssh://git@github.com:user/repo.git#branch"
  }
}

After (uses npm registry):

json
{
  "dependencies": {
    "my-package": "^1.2.3"
  }
}
5Clean reinstall of node_modules if issues persist

If removing individual .git folders doesn't resolve the issue, perform a clean reinstall:

bash
# Remove entire node_modules directory
rm -rf node_modules

# Clear npm cache
npm cache clean --force

# Reinstall dependencies
npm install
6Verify the fix and update package-lock.json

After resolving the issue, verify your installation is clean:

bash
# Check if git folders still exist
find node_modules -type d -name .git

# Should return nothing if successful

Then reinstall to update your lockfile:

bash
npm install

Advanced 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