node.js git 未安装或不在 PATH 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19290899/
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
git is not installed or not in the PATH
提问by lilyH
Windows, when I try to run npm install, it shows:
Windows,当我尝试运行时npm install,它显示:
[email protected] postinstall E:\mean
node node_modules/grunt-cli/bin/grunt install
Running "bower:install" (bower) task
Fatal error : git is not installed or not in the PATH
npm ERR! weird error 1
npm ERR! not ok code 0
What is the problem? How to fix it?
问题是什么?如何解决?
The project git repository is https://github.com/linnovate/mean
项目 git 仓库是https://github.com/linnovate/mean
回答by VtoCorleone
Did you install Git correctly?
你是否正确安装了 Git?
According to the Bower site, you need to make sure you check the option "Run Git from Windows Command Prompt".
根据 Bower 站点,您需要确保选中“从 Windows 命令提示符运行 Git”选项。
I had this issue where Git was not found when I was trying to install Angular. I re-ran the installer for git and changed my setting and then it worked.
我在尝试安装 Angular 时遇到了找不到 Git 的问题。我重新运行了 git 的安装程序并更改了我的设置,然后它起作用了。


From the bower site: http://bower.io/
来自凉亭网站:http: //bower.io/
回答by Daniel Egan
while @vitocorleone is technically correct. If you have already installed, there is no need to reinstall. You just need to add it to your path. You will find yourself doing this for many of the tools for the mean stack so you should get used to doing it. You don't want to have to be in the folder that holds the executable to run it.
而@vitocorleone 在技术上是正确的。如果您已经安装,则无需重新安装。你只需要将它添加到你的路径中。您会发现自己为许多用于均值堆栈的工具执行了此操作,因此您应该习惯于这样做。您不希望必须在包含可执行文件的文件夹中才能运行它。
- Control Panel --> System and Security --> System
- click on Advanced System Settings on the left.
- make sure you are on the advanced tab
- click the Environment Variables button on the bottom
- under system variables on the bottom find the Path variable
at the end of the line type (assuming this is where you installed it)
;C:\Program Files (x86)\git\cmd
click ok, ok, and ok to save
- 控制面板 --> 系统和安全 --> 系统
- 单击左侧的高级系统设置。
- 确保您位于高级选项卡上
- 单击底部的环境变量按钮
- 在底部的系统变量下找到 Path 变量
在行类型的末尾(假设这是您安装它的位置)
;C:\Program Files (x86)\git\cmd
单击确定、确定和确定以保存
This essentially tells the OS.. if you don't find this executable in the folder I am typing in, look in Path to fide where it is.
这实质上是告诉操作系统 .. 如果您在我输入的文件夹中没有找到此可执行文件,请查看 Path 以找到它的位置。
回答by profMamba
Installing git and running npm installfrom git-bash worked for me. Make sure you are in the correct directory.
安装 git 并从 git-bash运行npm install对我有用。确保您位于正确的目录中。
回答by Steve Barnes
Install gitand tortoise gitfor windows and make sure it is on your path, (the installer for Tortoise Git includes options for the command line tools and ensuring that it is on the path - select them).
为 windows安装git和tortoise git,并确保它在你的路径上,(Tortoise Git 的安装程序包括命令行工具的选项,并确保它在路径上 -选择它们)。
You will need to close and re-open any existing command line sessions for the changes to take effect.
您需要关闭并重新打开任何现有的命令行会话才能使更改生效。
Then you should be able to run npm installsuccessfully or move on to the next problem!
那么您应该能够npm install成功运行或继续下一个问题!
回答by MR AND
In my case the issue was not resolved because i did not restart my system. Please make sure you do restart your system.
就我而言,问题没有解决,因为我没有重新启动系统。请确保重新启动系统。
回答by S Debasish Nayak
If you installed GitHubDesktop then the path for git.exe will be ,
如果您安装了 GitHubDesktop,那么 git.exe 的路径将为,
C:\Users\<'Username'>\AppData\Local\GitHubDesktop\app-1.1.1\resources\app\git\cmd
C:\Users\<'用户名'>\AppData\Local\GitHubDesktop\app-1.1.1\resources\app\git\cmd
Add this path to the environment variables by following,
通过以下方式将此路径添加到环境变量中,
** (Note: \cmd at the end, not \cmd\git.exe).**
**(注意:最后是 \cmd,而不是 \cmd\git.exe)。**
Navigate to the Environmental Variables Editor and find the Path variable in the “System Variables” section. Click Edit… and paste the URL of Git to the end. Save!
导航到环境变量编辑器并在“系统变量”部分找到路径变量。单击 Edit... 并将 Git 的 URL 粘贴到最后。节省!
Now open a new cmd and type command git. If you are able to see the git usage then it's done.
现在打开一个新的 cmd 并输入命令 git。如果您能够看到 git 使用情况,那么它就完成了。
Now you can execute your command to install your package.
现在您可以执行您的命令来安装您的软件包。
ex: npm install native-base --save
例如: npm install native-base --save
回答by Tabrez Ansari
Go to Environmental Variables you will find this in Computer Properties->Advance system Setting->Environmental Variables -> Path
转到环境变量,您将在计算机属性-> 高级系统设置-> 环境变量-> 路径中找到它
Add the path of your git installed int the system. eg: "C:\Program Files\Git\cmd"
在系统中添加您的 git 安装路径。例如:“ C:\Program Files\Git\cmd”
Save it. Good to go now!!
保存。很高兴现在就去!!
回答by sver
I did install git and tried again and got the same error. But running 'npm install' in a new command prompt window worked for me. Restarting the machine is not required.
我确实安装了 git 并再次尝试并得到了同样的错误。但是在新的命令提示符窗口中运行“npm install”对我有用。不需要重新启动机器。
回答by Supun Dharmarathne
Use Git CMD instead of using Win CMD.
使用 Git CMD 而不是使用 Win CMD。

