安装失败 'react-navigation' 出现 GIT 不可用错误

Fail to install 'react-navigation' getting GIT not available error

我想使用 react-navigation 正如几个教程和官方文档中提到的那样,要使用反应导航,您必须使用 yarn 或 NPM 安装它。 我都试过了,但得到了同样的错误。

纱线

>yarn add react-navigation
yarn add v1.5.1
[1/4] Resolving packages...
error An unexpected error occurred: "Couldn't find the binary git".
info If you think this is a bug, please open a bug report with the information provided in "D:\projects\ReduxDemo\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

NPM

>yarn add react-navigation
yarn add v1.5.1
[1/4] Resolving packages...
error An unexpected error occurred: "Couldn't find the binary git".
info If you think this is a bug, please open a bug report with the information provided in "D:\projects\ReduxDemo\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

D:\projects\ReduxDemo>npm install --save react-navigation
npm WARN addRemoteGit Error: not found: git
npm WARN addRemoteGit     at getNotFoundError (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:14:12)
npm WARN addRemoteGit     at F (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:69:19)
npm WARN addRemoteGit     at E (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:81:29)
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:90:16
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\index.js:44:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\windows.js:29:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:264:29
npm WARN addRemoteGit     at FSReqWrap.oncomplete (fs.js:123:15)
npm WARN addRemoteGit  react-navigation/react-native-tab-view resetting remote C:\Users\AppData\Roaming\npm-cache\_git-remotes\git-github-com-react-navigation-react-native-tab-view-git-9747c439 because of error: { Error: not found: git
npm WARN addRemoteGit     at getNotFoundError (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:14:12)
npm WARN addRemoteGit     at F (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:69:19)
npm WARN addRemoteGit     at E (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:81:29)
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:90:16
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\index.js:44:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\windows.js:29:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:264:29
npm WARN addRemoteGit     at FSReqWrap.oncomplete (fs.js:123:15) code: 'ENOGIT' }
npm ERR! git clone --template=C:\Users\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror git://github.com/react-navigation/react-native-tab-view.git C:\Users\AppData\Roaming\npm-cache\_git-remotes\git-github-com-react-navigation-react-native-tab-view-git-9747c439: undefined
npm ERR! git clone --template=C:\Users\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror git://github.com/react-navigation/react-native-tab-view.git C:\Users\AppData\Roaming\npm-cache\_git-remotes\git-github-com-react-navigation-react-native-tab-view-git-9747c439: undefined
npm WARN addRemoteGit Error: not found: git
npm WARN addRemoteGit     at getNotFoundError (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:14:12)
npm WARN addRemoteGit     at F (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:69:19)
npm WARN addRemoteGit     at E (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:81:29)
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:90:16
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\index.js:44:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\windows.js:29:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:264:29
npm WARN addRemoteGit     at FSReqWrap.oncomplete (fs.js:123:15)
npm WARN addRemoteGit  react-navigation/react-native-tab-view resetting remote C:\Users\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-react-navigation-react-native-tab-view-git-0c5c085d because of error: { Error: not found: git
npm WARN addRemoteGit     at getNotFoundError (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:14:12)
npm WARN addRemoteGit     at F (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:69:19)
npm WARN addRemoteGit     at E (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:81:29)
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:90:16
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\index.js:44:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\windows.js:29:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:264:29
npm WARN addRemoteGit     at FSReqWrap.oncomplete (fs.js:123:15) code: 'ENOGIT' }
npm ERR! git clone --template=C:\Users\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror https://github.com/react-navigation/react-native-tab-view.git C:\Users\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-react-navigation-react-native-tab-view-git-0c5c085d: undefined
npm ERR! git clone --template=C:\Users\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror https://github.com/react-navigation/react-native-tab-view.git C:\Users\AppData\Roaming\npm-cache\_git-remotes\git-https-github-com-react-navigation-react-native-tab-view-git-0c5c085d: undefined
npm WARN addRemoteGit Error: not found: git
npm WARN addRemoteGit     at getNotFoundError (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:14:12)
npm WARN addRemoteGit     at F (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:69:19)
npm WARN addRemoteGit     at E (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:81:29)
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:90:16
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\index.js:44:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\windows.js:29:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:264:29
npm WARN addRemoteGit     at FSReqWrap.oncomplete (fs.js:123:15)
npm WARN addRemoteGit  react-navigation/react-native-tab-view resetting remote C:\Users\AppData\Roaming\npm-cache\_git-remotes\git-github-com-react-navigation-react-native-tab-view-git-b354594d because of error: { Error: not found: git
npm WARN addRemoteGit     at getNotFoundError (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:14:12)
npm WARN addRemoteGit     at F (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:69:19)
npm WARN addRemoteGit     at E (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:81:29)
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:90:16
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\index.js:44:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\windows.js:29:5
npm WARN addRemoteGit     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:264:29
npm WARN addRemoteGit     at FSReqWrap.oncomplete (fs.js:123:15) code: 'ENOGIT' }
npm ERR! git clone --template=C:\Users\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror git@github.com:react-navigation/react-native-tab-view.git C:\Users\AppData\Roaming\npm-cache\_git-remotes\git-github-com-react-navigation-react-native-tab-view-git-b354594d: undefined
npm ERR! git clone --template=C:\Users\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror git@github.com:react-navigation/react-native-tab-view.git C:\Users\AppData\Roaming\npm-cache\_git-remotes\git-github-com-react-navigation-react-native-tab-view-git-b354594d: undefined
npm ERR! Windows_NT 10.0.16299
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "--save" "react-navigation"
npm ERR! node v6.11.4
npm ERR! npm  v3.10.10
npm ERR! code ENOGIT

npm ERR! not found: git
npm ERR!
npm ERR! Failed using git.
npm ERR! This is most likely not a problem with npm itself.
npm ERR! Please check if you have git installed and in your PATH.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\projects\ReduxDemo\npm-debug.log

几天前我遇到了同样的问题。我通过安装 "Git" 解决了这个问题,你可以在这里得到它:Git Download

在安装它时,您应该检查安装说明中的一个选项。它类似于将 git 添加到 cmd 或路径。之后你应该再次尝试安装导航包。它对我有用,但我不知道它是否适合你。

您之前需要git安装应该可以在 path

您可以使用 git --version 查看它。

到那时你可以直接引用特定版本yarn add react-navigation@1.5.1

我也有同样的问题,它与您在项目中使用的其他版本的库有冲突,我使用的是 react-native-image-picker.so 它会出错。 所以当安装下面的版本时它工作正常。

npm install --save react-navigation@1.0.0-beta.27

这解决了我的问题

假设您已经安装了 GIT,转到您想要 运行 的目录,然后右键单击 git bash 此处然后 运行命令。 它对我有用!