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

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 ./do-something.sh"
).
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! code ELIFECYCLE
npm ERR! errno 1
npm ERR! asciidoctor-packt@1.0.0 clean-assets: `bash ./build.sh clean_assets`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the asciidoctor-packt@1.0.0 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: https://stackoverflow.com/questions/23243353/how-to-set-shell-for-npm-run-scripts-in-windows
That's it for today! ✨
About Sébastien
I'm Sébastien Dubois, and I'm on a mission to help knowledge workers escape information overload. After 20+ years in IT and seeing too many brilliant minds drowning in digital chaos, I've decided to help people build systems that actually work. Through the Knowii Community, my courses, products & services and my Website, I share practical and battle-tested systems. You can follow me on X 🐦 and on BlueSky 🦋.
I am an author, founder, and coach. I write books and articles about Knowledge Work, Personal Knowledge Management, Note-taking, Lifelong Learning, Personal Organization, and Zen Productivity. I also craft lovely digital products.
If you want to follow my work, then become a member and join our community.
Ready to get to the next level?
If you're tired of information overwhelm and ready to build a reliable knowledge system:
- 🎯 Join Knowii and get access to my complete knowledge transformation system
- 📚 Take the Course and Master Knowledge Management
- 🚀 Start with a Rock-solid System: the Obsidian Starter Kit
- 🦉 Get Personal Coaching: Work with me 1-on-1
- 🛒 Check out my other products and services. These will give you a rock-solid starting point for your note-taking and Knowledge Management efforts