Skip to content

Fixing ‘bash’ is not recognized as an internal or external command when used within npm scripts on Windows

Sébastien Dubois /

2 min read


Recently, I’ve lost quite a bit of time figuring why npm scripts would suddenly fail on Windows under Git bash if they tried to execute bash (e.g., "do-something": "bash ./").

I was executing the npm scripts from Git Bash as usual, so of course bash.exe was on my path but, it wasn’t found in the environment tied to the process for the script execution:

‘bash’ is not recognized as an internal or external command,
operable program or batch file.
npm ERR! errno 1
npm ERR! [email protected] clean-assets: `bash ./ clean_assets`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] clean-assets script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

To my surprise, after digging for a while, I’ve realized that the script was executed under cmd.exe.

Apparently, since npm 5, we can select the shell to use by defining the “script-shell” setting in the npm config:

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

After setting this, my problem was directly fixed.

Hope this helps! :)

For reference, I found this related SO question:

That's it for today! ✨

About Sébastien

Hello everyone! I'm Sébastien Dubois. I'm an author, founder, and CTO. I write books and articles about software development & IT, personal knowledge management, personal organization, and productivity. I also craft lovely digital products 🚀

If you've enjoyed this article and want to read more like this, then subscribe to my newsletter, check out my PKM Library and my collection of books about software development 🔥.

You can follow me on Twitter 🐦

If you want to discuss, then don't hesitate to join one of my communities: the Software Crafters community, the Personal Knowledge Management community, and the focusd Productivity community
Subscribe to my newsletter
Weekly newsletter discussing personal knowledge management, software development, building in public and productivity