错误:"git"命令行工具未安装:

12

我正在努力尝试:

cordova plugins add https://github.com/wildabeast/BarcodeScanner.git

但我得到的是:

Error: "git" command line tool is not installed:
make sure it is accessible on your PATH.

那么我就这样做:

npm install -g git 

看起来它将它安装在这里:

c:\Users\Phillip\AppData\Roaming\npm\node_modules\git

那么我应该将它添加到现有的路径中吗?

C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\AdobeAIRSDK\bin;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;c:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\nodejs\;C:\apache-ant\bin;C:\Development\adt-bundle\sdk\platform-tools;C:\Development\adt-bundle\sdk\tools;%JAVA_HOME%\bin;C:\AndroidDevelopmentKit\adt-bundle-windows-x86_64-20131030\sdk\platform-tools;C:\AndroidDevelopmentKit\adt-bundle-windows-x86_64-20131030\sdk\tools

还是应该添加除c:\Users\Phillip\AppData\Roaming\npm\node_modules\git之外的其他内容?因为我在那里看不到可执行文件。


3
npm install -g git 安装了适用于 Node.js 的 Git 模块,它是一个可以与 Git 交互的 JavaScript 扩展库。如果想要安装实际的 Git 软件,请前往 msysgit 下载并将其路径加入到您的 PATH 环境变量中。请注意保持原意,同时让语言更为通俗易懂。 - wkl
5个回答

11
npm install -g git

这将安装NPM包git(也称为node-git)。这不同于可用作命令行实用程序的真正的Git。前者是基本上一个利用Git功能的Node JS模块。正如该项目所解释的那样,它还包含一些本地操作,但对于许多其他操作,它需要回退到命令行实用程序。

因此,您应该只安装真正的Git


9
你需要安装git可执行文件。请查看此处的Windows部分以获取有关如何安装它的说明:Git安装Msysgit

6

开始菜单 > 系统属性 > 系统高级配置 > 环境变量。 进入系统变量并找到 "Path" 变量,点击 "编辑",然后转到值的结尾,在分号 (;) 后粘贴您的 git 路径(我的是:C:\Program Files\Git\bin)。保存即可完成。


3

如果您已经安装了Git,但仍然遇到问题,则有两种解决方法:

1. 在环境变量中添加"C:\Program Files\Git\bin"和"C:\Program Files\Git\cmd"路径。重新启动计算机。

2. 第二种解决方法是卸载并重新安装(https://git-scm.com/downloads),然后执行步骤1。


3
我也遇到了同样的问题,尝试了上述所有解决方案,但仍然遇到相同的问题。于是我检查了我的环境变量中的“Path”,发现它已经有了(C:\Program Files\Git\cmd;),而我正在添加(C:\Program Files\Git\bin;)。所以这会创建一个冲突。 然后我删除了(C:\Program Files\Git\cmd;),并将(C:\Program Files\Git\bin;)附加到我的路径中。关闭命令提示符,再次在相同目录下输入相同的"add plugin"命令,就可以解决问题了!

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接