在 Gitbash - Bower 上:ENOGIT git 未安装或不在 PATH 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31488176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:12:50  来源:igfitidea点击:

On Gitbash - Bower : ENOGIT git is not installed or not in the PATH

node.jsgitbower

提问by Lihai

I have a project with bower.json file and im trying to load all it's bower libraries on Windows. I turn on Gitbash, cd to that project directory and type in bower install / bower update. I receive an error:

我有一个带有 bower.json 文件的项目,我正在尝试在 Windows 上加载它的所有 bower 库。我打开 Gitbash,cd 到该项目目录并输入 bower install / bower update。我收到一个错误:

bower ENOGIT        git is not installed or not in the PATH

But there is a path to git:

但是有一条通往 git 的道路:

$ which git
/bin/git

So the wierd thing that it actually works in cmd on Windows, but it doesnt work with Gitbash. This is the value i have in the system PATH env variable regarding git:

所以奇怪的是,它实际上在 Windows 上的 cmd 中有效,但它不适用于 Gitbash。这是我在系统 PATH 环境变量中关于 git 的值:

C:\Program Files (x86)\Develop\VCS\Git\cmd

I tried to re-install msysgit and chose the option: Run Git From Windows Command Prompt like so:

我尝试重新安装 msysgit 并选择了以下选项:从 Windows 命令提示符运行 Git,如下所示:

enter image description here

在此处输入图片说明

It still doesnt seem to work..

好像还是不行。。

Bower version:

鲍尔版本:

$ bower --version
1.4.1

Git version:

git版本:

$ git --version
git version 1.9.5.msysgit.1
  • Bower is installed globally using npm
  • Bower 使用 npm 全局安装

EDIT: I found the cause of this issue: I have a file in my profile home directory .bashrc that i usually use in order to define general aliases and so on and i added this line:

编辑:我找到了这个问题的原因:我的个人资料主目录 .bashrc 中有一个文件,我通常使用它来定义一般别名等,我添加了这一行:

export PATH="~/AppData/Roaming/Composer/vendor/bin":$PATH

And somehow when this line is present i receive the error in Gitbash, wierd though, it just add the path to global composer packages, what it has to do with git itself or bower?

不知何故,当这条线出现时,我在 Gitbash 中收到错误,虽然奇怪,但它只是添加了全局作曲家包的路径,它与 git 本身或 bower 有什么关系?

回答by Felipe González

Check this solution posted by saurabhkohliin this GitHub issue:

检查saurabhkohli此 GitHub 问题中发布的此解决方案:

[U]pdating the PATH environment variable with the current installed location of the GIT in your system will help resolve this issue, or you can update the same in your NodeJS command prompt by using "set PATH=%PATH%;C:\Program Files\Git\bin;"

[U]使用系统中 GIT 的当前安装位置更新 PATH 环境变量将有助于解决此问题,或者您可以在 NodeJS 命令提示符中使用 "set PATH=%PATH%;C:\Program Files\Git\bin;"

回答by Marco Leite

I just hit the same issue when trying to use windows command line. Turns out, you have to select this setting twice and I have missed the second one.

我在尝试使用 Windows 命令行时遇到了同样的问题。事实证明,您必须选择此设置两次,而我错过了第二次。

Here's a few screenshots if any help for anyone:

如果对任何人有帮助,这里有一些屏幕截图:

i

一世

The one I have missed: j

我错过的一个: j

After reinstalling with the above settings, everything seem to be ok.

使用上述设置重新安装后,似乎一切正常。

回答by VonC

Try to unzip a portable Git in a simpler path (no space).
Take the latest one from git for Windows: PortableGit-2.4.5.1-4th-release-candidate-64-bit.7z.exe.
(no setup required, just an auto-extractable archive here)

尝试以更简单的路径(无空格)解压缩便携式 Git。
从 git for Windows 中获取最新的一个:PortableGit-2.4.5.1-4th-release-candidate-64-bit.7z.exe.
(无需设置,这里只是一个可自动提取的存档)

Remove from your PATHthe old msysgit, and add C:\path\to\PortableGit-2.4.5.1-4th-release-candidate-64-bit\binto the %PATH%.

PATH旧的 msysgit 中删除,然后添加C:\path\to\PortableGit-2.4.5.1-4th-release-candidate-64-bit\bin%PATH%.