# Run npm scripts through Bash instead of cmd.exe On Windows, [npm scripts](https://docs.npmjs.com/misc/scripts) run under [cmd.exe](https://en.wikipedia.org/wiki/Cmd.exe). If you have [Git for Windows](https://git-for-windows.github.io/) installed, you can make [npm scripts](https://docs.npmjs.com/misc/scripts) run under [Bash](https://en.wikipedia.org/wiki/Bash_%28Unix_shell%29). This allows you to somewhat mimic a Linux or macOS environment. Check to see where npm is installed: ```bash npm ls -g --depth=0 ``` If you are using the npm that comes with Node.js, edit the file: `C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js` If you have updated npm, edit the file: `C:\Users\__USERNAME__\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js` ```diff if (!unsafe) { conf.uid = uid ^ 0 conf.gid = gid ^ 0 } var sh = 'sh' var shFlag = '-c' if (process.platform === 'win32') { - sh = process.env.comspec || 'cmd' - shFlag = '/d /s /c' - conf.windowsVerbatimArguments = true + sh = 'C:\\Program Files\\Git\\usr\\bin\\bash.exe' } log.verbose('lifecycle', logid(pkg, stage), 'PATH:', env[PATH]) log.verbose('lifecycle', logid(pkg, stage), 'CWD:', wd) log.silly('lifecycle', logid(pkg, stage), 'Args:', [shFlag, cmd]) var proc = spawn(sh, [shFlag, cmd], conf) proc.on('error', procError) proc.on('close', function (code, signal) { ``` > **Note:** After an update the file will be overwritten, so you will need to apply the changes again. > > **Tested on:** npm 4.6.1