使用 npm 安装 react-native-gesture-handler 时出错

Error when installing react-native-gesture-handler with npm

我正在尝试 运行 npm install react-native-gesture-handler 但我的终端给我这个错误:

SAMETs-MBP:HelloWorld developer$ npm install react-native-gesture-handler
npm ERR! path /Users/developer/HelloWorld/node_modules/react-native-safe-area-view
npm ERR! code EISGIT
npm ERR! git /Users/developer/HelloWorld/node_modules/react-native-safe-area-view: Appears to be a git repo or submodule.
npm ERR! git     /Users/developer/HelloWorld/node_modules/react-native-safe-area-view
npm ERR! git Refusing to remove it. Update manually,
npm ERR! git or move it out of the way first.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/developer/.npm/_logs/2019-05-14T05_27_08_555Z-debug.log

谁能帮我解决这个问题?我在网上搜索但找不到任何东西。

使用纱线。使用 npm 给了我一个错误。我尝试使用 yarn,它没有给出任何问题。

我今天遇到了同样的问题。尝试了三个步骤,成功了!

  1. 手动删除了文件夹'react-native-safe-area-view'
  2. 已使用 npm start -- --reset-cache
  3. 删除缓存
  4. 运行命令npm --save install react-native-gesture-handler

更新:我还发现删除 node_modules/react-native-safe-area-view 中的 git 文件夹将解决此问题。谢谢@ThaJay

希望对您有所帮助!

只需删除 your_project_dir/node_modules/react-native-safe-area-view 中的 .git 文件夹即可。 它对我有用。

运行 rm -rf node_modules/*/.git/ 从根文件夹解决了我的问题。参考 https://github.com/react-native-community/react-native-safe-area-view/issues/73