react-native-version-number: Repeatedly performing npm-install fails with EISGIT: Appears to be a git repo or submodule

When repeatedly performing npm install with a dependency on react-native-version-number, npm fails with the error code EISGIT.

I have declared a dependency on on react-native-version-number in my package.json like so:

  ...
  "dependencies": {
    "react-native-version-number": ">=0.2.0",
    ...
  },
  ...

Performing npm install for the first time succeeds. Performing npm install immediately again will fail:

$ rm -rf node_modules/
$ npm install
$ <installation succeeds>
$
$ npm install
npm ERR! path <path/to/project/root>/node_modules/react-native-version-number
npm ERR! code EISGIT
npm ERR! git <path/to/project/root>/node_modules/react-native-version-number: Appears to be a git repo or submodule.
npm ERR! git     <path/to/project/root>/node_modules/react-native-version-number
npm ERR! git Refusing to remove it. Update manually,
npm ERR! git or move it out of the way first.

When inspecting the installed react-native-version-number module in node_modules, I found that the module contains a .git file.

Any help resolving this failure would be much appreciated. Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 50
  • Comments: 43 (1 by maintainers)

Commits related to this issue

Most upvoted comments

+1 I am also having this issue. As @alexgvozden mentions, the package needs to be updated to remove the .git directory from the package. As a temporary fix for @sdduursma , just go into the directory and use rm -rf .git this will stop NPM complaining.

seems that project owner needs to remove git repository from the package…

Bump 😅

add this to your package.json file in the scripts json part

"scripts": {
    ...,
    "preinstall": "rm -rf node_modules/react-native-safe-area-view/.git"
  },

@kkjdaniel 's solution got this work!

remove any .git files present in the node_modules folder

In your terminal, from your project folder: rm -rf node_modules/*/.git

+1 I am also having this issue. As @alexgvozden mentions, the package needs to be updated to remove the .git directory from the package. As a temporary fix for @sdduursma , just go into the directory and use rm -rf .git this will stop NPM complaining.

you can use rm -rf node_modules/package_name/.git/ in root terminal…

rm -rf .git

i did his coomand from my project root folder and i lost my .git file and the branches,make sure you dont use this command in wrong place

Is this project dead?

same issue, and have to manually remove .git directory inside the package

Having same issue

Will try to do it later, @VinceBT. Cool avatar BTW 😉

i solved this problem by removing it before performing npm install again as it suggests.

add this to your package.json file in the scripts json part

"scripts": {
    ...,
    "preinstall": "rm -rf node_modules/react-native-safe-area-view/.git"
  },

I also use:

"postinstall": "rm -rf node_modules/react-native-safe-area-view/.git"

so that if npm install is run then it removes it after installing also.

Therefore I have:

  "scripts": {
    ...,
    "preinstall": "rm -rf node_modules/react-native-safe-area-view/.git",
    "postinstall": "rm -rf node_modules/react-native-safe-area-view/.git"
  },

+1 I am also having this issue. As @alexgvozden mentions, the package needs to be updated to remove the .git directory from the package. As a temporary fix for @sdduursma , just go into the directory and use rm -rf .git this will stop NPM complaining.

I don’t care if this was 2+ years ago. This was the fix for me and I want to say that I love you.

add this to your package.json file in the scripts json part

"scripts": {
    ...,
    "preinstall": "rm -rf node_modules/react-native-safe-area-view/.git"
  },

this works perfectly. thank you

Same problem while installing moment package. npm install --save moment

it say react-native-safe-area-view is a git repo.

I’ve remove the .git folder and it’s works. Are they a reason to put the .git into the package ?

Ubuntu 18.4 i had same issue fixing by going to given directory and remove .git " rm -rf .git " in my case : /home/lenovo/Desktop/native/fun/jobs/node_modules/react-native-safe-area-view

Hey,

I don’t want to delete the .git folder in one of the npm packages, since I’m checking out the latest updates for this package from the repo. Thus, I’m not able to install other npm packages, since it keeps complaining, that this particular package has a git repo.

How to proceed? Or: What’s the reason of this behavior?

+1 I am also having this issue. As @alexgvozden mentions, the package needs to be updated to remove the .git directory from the package. As a temporary fix for @sdduursma , just go into the directory and use rm -rf .git this will stop NPM complaining.

This^ worked for me since I had a custom module (not from) npm installed and it had a .git hidden folder tracking it. Thanks @kkjdaniel !