Is it possible to run JavaScript files from the command line?

Expanding upon the solution to use Node.js…

Here are some examples and screenshots from a page on Command Line JavaScript.

The Node REPL (Shell)

If you enter node on the command line with no arguments, you’ll be in the Read-Eval-Print-Loop, or REPL for short, otherwise known as a shell. Here you can interactively enter JavaScript expressions and have them immediately evaluated.

Node REPL (Shell)

Evaluate a JavaScript file from the command line

Create a file with the following content:

console.log('Hello, world');

From the command line, use node to evaluate the file:

Evaluate a JavaScript file

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)