-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
What / Why
I'm running Windows 10 build 19041, npm version 6.14.4, and git version 2.27.0.windows.1.
When I run git submodule
, it works as expected and exits without error. But when I create an npm script in my package.json
like this:
"scripts": {
"sth": "git submodule"
}
And try to run it like npm run sth
, it gives me this error:
> test-project@0.1.0 sth D:\...\test-project
> git submodule
D:/Program_Files/Git/mingw64/libexec/git-core\git-submodule: line 22: .: git-sh-setup: file not found
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-project@0.1.0 sth: `git submodule`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-project@0.1.0 sth script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\.....
When
- n/a
Where
- n/a
How
When git
is run from an npm
script, it cannot add the git-core
path to the PATH environment variable, and it fails to execute its bash scripts.
Current Behavior
When I run git submodule
normally, this is prepended to the PATH:
/mingw64/libexec/git-core
But when I run it from within an npm script, this is instead prepended:
/d/Program_Files/nodejs/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/d/Shayan/MyDocuments/Coding/SampleProject/node_modules/.bin
(I got this info by adding a line (echo "$PATH"
) to my git-submodule
script in git's installation directory.)
Steps to Reproduce
Add a script like "sth": "git submodule"
to your package.json
and run it like npm run sth
.
Expected Behavior
When I run git submodule
from within an npm script, git-core
path is also prepended in addition to npm-related paths. I expect my PATH environment variable to look like this:
/mingw64/libexec/git-core:/d/Program_Files/nodejs/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/d/Shayan/MyDocuments/Coding/SampleProject/node_modules/.bin
Who
- n/a
References
- n/a