When the command grunt is run in a Windows shell in the same path as the grunt.js file, Windows opts to run grunt.js using the Windows Script Host. The recommended path is to explicitly call grunt.cmd.
That’s all fine and dandy, but what can I do if I want to create an OS-independent script command in my NPM package.json? I can’t do this if I want to also run in *nix:
"scripts": {
"dox": "grunt.cmd dox"
}
Any pointers? Or, is there a big piece of the puzzle that I’m missing? (I’m equally new to both NPM and Grunt).
I’ve found the solution in creating a
grunt.batfile that just callsgrunt.cmd:Therefore, on Windows, just invoking
grunttriggers the batch file since it gets higher priority than Windows Scripting Host’s picking up ofgrunt.js. On Linux, the regulargruntbinary gets picked up. This works cross-platform for me now.