Portability option 4: prefix all commands with bash -c . if you have Msys bash shell or Bash on unbuntu on windows it runs in bash and on *nix with bash it just runs a sub shell. Unfortunately this is not so practical as correct quoting soon gets crazy as the command must be surrounded by “s. Also some OS like BSD had sh rather than bash, though it otherwise doesn’t normally matter.
On Windows npm always runs a cmd shell rather than invoking which ever shell you call npm from. I and others have tried at various time to get them to address this but they are nervious of breaking changes. Hopefully now we have Bash on Ubuntu on windows this may soon change.