'npm ERR! errno -4058 while running npm run start-rewired

I run my React app using npm using the following command npm run start-rewired. However, in doing so, I'm getting the below error:

> [email protected] start-rewired
> react-app-rewired start

npm ERR! code ENOENT
npm ERR! syscall spawn C:\Program Files\git\bin\bash.exe
npm ERR! path C:\project
npm ERR! errno -4058
npm ERR! enoent spawn C:\Program Files\git\bin\bash.exe 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\{my-user}\AppData\Local\npm-cache\_logs\2022-03-16T15_34_33_074Z-debug-0.log

I have followed a lot of the suggestions online, including deleting the node_modules as well as clearing the npm cache using npm cache clean

I'm running npm run start-rewired in the root path of my project. I should mention that I use yarn to install the dependencies and packages, and that running yarn install worked fine.

I'm really stuck and I'm unsure on what to do at this point.

EDIT I should also mention that this project starts up fine on a different machine with the same node and npm versions.



Solution 1:[1]

This issue was due to the fact that npm couldn't find the bash.exe location for git. It was looking here C:\Program Files\git\bin\bash.exe but git was installed in a different location. So what I did was uninstall and reinstall git in the above location and it resolved the issue.

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 Adam