47

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 project git repository is https://github.com/linnovate/mean

lilyH
  • 481
  • 1
  • 5
  • 7

10 Answers10

82

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/

VtoCorleone
  • 16,813
  • 5
  • 37
  • 51
  • 3
    Also, if any of your paths in the global PATH variable are in "quotes", it may not work in git bash on windows. I had this issue with nodejs and npm. They were in my PATH and worked fine in thewindows command prompt, but wouldn't in git bash until I removed the quotes surrounding their path. You can type "echo $PATH" in git bash to check. – Jordan Jun 17 '15 at 23:06
  • Thanks @Triad and consider to upgrade your comment to an answer ;) – malarres Oct 30 '15 at 11:40
24

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.

Daniel Egan
  • 454
  • 4
  • 8
21

Installing git and running npm install from git-bash worked for me. Make sure you are in the correct directory.

profMamba
  • 988
  • 1
  • 14
  • 29
9

Install git and tortoise git for 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).

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 install successfully or move on to the next problem!

Steve Barnes
  • 27,618
  • 6
  • 63
  • 73
3

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

MR AND
  • 376
  • 7
  • 29
2

If you installed GitHubDesktop then the path for git.exe will be ,

C:\Users\<'Username'>\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).**

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!

Now open a new cmd and type command git. If you are able to see the git usage then it's done.

Now you can execute your command to install your package.

ex: npm install native-base --save

0

Use Git CMD instead of using Win CMD.

Supun Dharmarathne
  • 1,138
  • 1
  • 10
  • 19
0

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.

sver
  • 866
  • 1
  • 19
  • 44
0

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!!

0

The issue depends on the command prompt you are using. if you are using your Windows cmd, then it will be fine if you have installed git in your system (note that after installation it gets added to your system path). if you are running on an Anaconda terminal or any other, then you need to install git on your project environment from the terminal.

for anaconda, the problem gets solved by running:

conda install git

Mosius
  • 1,602
  • 23
  • 32