Friday 14 April 2017

How can I run a JavaScript automatically on a command-line?

I have a simple JavaScript myScript.js with code as below;

var printer = function(someString){
    console.log(someString);
}

printer("This is printed on console.");

I'm on Windows 10 and need to be able to call myScript.js on a command prompt and have the code executed without doing node myScript.js. Is there a way to set up things so that Command prompt or PowerShell can automatically call Nodejs or other JavaScript engine?



via Amani

No comments:

Post a Comment