git is not installed or not in the PATH

2020-01-30 08:24发布

Windows, when I try to run npm install, it shows:

mean@1.0.0 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 progrect is from https://github.com/linnovate/mean

9条回答
成全新的幸福
2楼-- · 2020-01-30 08:36

In my case the issue was not resolved because i did not restart my system. Please make sure you do restart your system.

查看更多
甜甜的少女心
3楼-- · 2020-01-30 08:37

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.

  • 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

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.

查看更多
甜甜的少女心
4楼-- · 2020-01-30 08:44

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"

Save it. Good to go now!!

查看更多
可以哭但决不认输i
5楼-- · 2020-01-30 08:48

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.

查看更多
相关推荐>>
6楼-- · 2020-01-30 08:49

Use Git CMD instead of using Win CMD.

查看更多
干净又极端
7楼-- · 2020-01-30 08:52

Did you install Git correctly?

According to the Bower site, you need to make sure you check the option "Run Git from Windows Command Prompt".

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.

enter image description here

From the bower site: http://bower.io/

查看更多
登录 后发表回答