Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

bash

windows

cmd

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?

like image 930
Manu Chadha Avatar asked Dec 04 '25 13:12

Manu Chadha


1 Answers

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

  • use windows path separators (\ instead of /).
  • not prefix by ./ to run something.

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
like image 62
Frédéric Branca Avatar answered Dec 06 '25 07:12

Frédéric Branca