'npm install returns syscall spawn git error

I've tried to run npm install and faced these issues below

I've tried to clear cache with force command, install git and update node but nothing worked

here is the error

npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno ENOENT
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://[email protected]/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:
npm ERR!     C:\Users\UserName\AppData\Roaming\npm-cache\_logs\2019-11-01T11_56_42_862Z-debug.log

Can someone help me resolve this?



Solution 1:[1]

Make sure you have the GIT installed on your device and accessible globally. Try to type git --version in the CMD. If it returned that the command is not recognized and GIT already installed, then you need to add it to the PATH environment variable and make sure to try the command using a new CMD session

Solution 2:[2]

If you're using a docker image, alpine version do not include git. Either switch to a non-alpine version (e.g. node:16 instead of node:16-alpine) or install git in another way (more info here).

Solution 3:[3]

Error means that 'git' is not recognized from the path/folder where you are trying to install.

  1. For this, you can Add/Map environmental variables of Git.
  2. Without mapping env variables, You can easily use Gitbash Terminal to get it installed easily. Example: In git bash terminal, run the command: npm install git+https://github.com/abc.git replace the git url with actual url of yours.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2
Solution 3 Maniarasi Kumaravel