22

I have recently added some dependencies to the package JSON and tried installing npm, but it shows errors related to git not found:

npm ERR! path git
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! syscall spawn git
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent
npm ERR! A complete log of this run can be found in:

Image

Ooker
  • 1,969
  • 4
  • 28
  • 58
Harikrishnan C U
  • 239
  • 1
  • 2
  • 5

2 Answers2

30

You need to install git in your machine to have it working.

undefined ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git

it should have been

git ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git

There is error related to git path. check this ls-remote command

Shashank Vivek
  • 16,888
  • 8
  • 62
  • 104
  • I tried the same > git ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git command. After reruning yarn producing below error.. – Omprakash Sharma Oct 28 '22 at 15:28
  • warning Pattern ["file-saver@eligrey/FileSaver.js#1.3.8"] is trying to unpack in the same destination "C:\\Users\\[xyz]\\AppData\\Local\\Yarn\\Cache\\v1\ pm-file-saver-2.0.5-cea522bc41bfadc364" as pattern ["file-saver@github:eligrey/FileSaver.js"]. This could result in non-deterministic behavior, skipping. error Command failed. Exit code: 128 Command: git Arguments: ls-remote --tags --heads ssh://git@github.com/eligrey/FileSaver.js.git Directory: C:\Users\[xyz]\git\[repo] Output: git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. – Omprakash Sharma Oct 28 '22 at 15:29
11

In my case, I had Git installed, but it was only accessible from Git Bash (I had selected the first option below when installing). I reinstalled with the second option and it solved the issue:

enter image description here

Saeb Amini
  • 23,054
  • 9
  • 78
  • 76