D
D
danilr2020-10-24 18:11:53
bash
danilr, 2020-10-24 18:11:53

Why doesn't the script work when run via npm script?

Please tell me, I really want to solve the problem - I don’t understand why a script launched directly in bash works fine, but if it is written in scripts npm, then when it starts it does not understand anything as if. PS This is on MacOs everything works this way and that, on Windows there is such garbage:

...
"scripts": {
   "setFile": "FILE=./swagger/email.yaml; name=$(basename ${FILE%.*}); echo $FILE, $name;"
},
...

5f944432c3411941401802.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
danilr, 2020-10-24
@danilr

Decision!
Indeed, npm calls its cmd or powershell scripts to execute, but bash is needed - for this we run the command to change the launch environment

npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"

You can return as it was the team
npm config delete script-shell
Thank you all!)

S
Saboteur, 2020-10-24
@saboteur_kiev

Because bash for Windows is not a native shell, and therefore the npm script on Windows will not run the bash interpreter, but most likely cmd or powershell

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question