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.
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.
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"
}
}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.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error