windowsbashcmd

How can I execute a node script (#!/usr/bin/env node) on Windows?


I want to check version of protractor command on my windows machine. I typed following but it didnt work. why? The path is correct.

./node_modules/protractor/bin/protractor --version
'.' is not recognized as an internal or external command,
operable program or batch file.

The file is a script -

#!/usr/bin/env node

process.env.NODE_ENV = process.env.NODE_ENV || 'test';

require('../built/cli.js');

I could run it using Bash in Windows but is there a way to run it on CMD?


Solution

  • If you are using the command prompt of windows (cmd.exe) you should :

    Also keep in mind that the first line of your script is not understood by the windows shell. So you should explicitly call the node interpreter.

    Assuming the node interpreter is in the PATH, in your case you should type :

    node node_modules\protractor\bin\protractor --version