How to run JavaScript in the command-line environment

; Date: Fri Jun 15 2018

Tags: Node.JS »»»» JavaScript

JavaScript is an extremely popular programming language deserving of a bigger role than browser-based programming. Fortunately we can use JavaScript outside web browsers, because of several non-browser JavaScript implementations. The most popular, Node.js, is not the only choice for running JavaScript outside the web browser.

As I wrote in Node.JS Web Development - Fourth Edition -- Quit scratching your head already! Of course you're doing it, scratching your head and mumbling to yourself "What's a browser language doing on the server?"

JavaScript has had a long history in non-browser contexts. It was never a browser-only language, even though that has been its primary use for nearly the entire lifespan of the JavaScript language. JavaScript is a programming language, just like any other language, and the better question to as is: "Why should JavaScript remain trapped inside browsers?"



Obviously Node.js is a JavaScript platform that runs standalone. While its primary use is server-side applications, it can be used for command-line tools, GUI applications (using Electron), and much more.

Node.js is available for pretty much every computing platform from embedded linux boards up to massive mainframes. It is used for projects from little one-off scripts, to clouds of microservices, to massive systems.


( docs Mozilla Projects Rhino

Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically embedded into Java applications to provide scripting to end users. It is embedded in Java 6 distribution as the default Java scripting engine. It was since dropped from the Java distribution in favor of another JavaScript implementation.

As a Java application it can run anywhere Java is available. That means pretty much every computing platform from embedded linux boards up to massive mainframes.


( projects nashorn

Nashorn replaced Rhino as the default JavaScript implementation for the Java platform. It uses newer JVM technologies than did Rhino, the MethodHandles and InvokeDynamic APIs described in JSR-292, and therefore has better performance.

Free standing JavaScript applications using the jrunscript command-line tool. ( javase 7 docs technotes tools share jrunscript.html



Ringo is a JavaScript platform built on the JVM and optimized for server-side applications. It takes a non-dogmatic stance on things like I/O paradigms. Ringo ships with a large set of built-in modules and follows the CommonJS standard.

It is based on the Rhino engine. It includes a command-line tool, ringo for directly running JavaScript code.

As it uses CommonJS modules, along with the package.json file, it will be instantly familiar to Node.js programmers. However, it does not use Node.js modules.



This is billed as "JavaScript for Microcontrollers". The boards are similar in scope to the Arduino, hence the name, with a JavaScript-based runtime.

Low.js - Neonius



Low.js is a fork of Node.js that runs on embedded microcontrollers. It uses Duktape as the JavaScript engine rather than V8.

Neonious is an embedded microcontroller with full Node.js API compatibility, supporting ES6 features, and can even use the TypeScript language.



This is an embeddable JavaScript interpreter, that is used in Low.js. It can run on embedded devices as small as 160kB flash and 64kB system RAM. It supports Ecmascript E5/E5.1, with some semantics updated from ES2015+.



A JavaScript engine for Internet of Things. JerryScript is the lightweight JavaScript engine intended to run on a very constrained devices such as microcontrollers: a) Only few kilobytes of RAM available to the engine (<64 KB RAM) b) Constrained ROM space for the code of the engine (<200 KB ROM). The engine supports on-device compilation, execution and provides access to peripherals from JavaScript.



MuJS is a lightweight Javascript interpreter designed for embedding in other software to extend them with scripting capabilities. MuJS was designed with a focus on small size, correctness, and simplicity. It is written in portable C and implements ECMAScript as specified by ECMA-262. The interface for binding with native code is designed to be as simple as possible to use, and is very similar to Lua. There is no need to interact with byzantine C++ template mechanisms, or worry about marking and unmarking garbage collection roots, or wrestle with obscure build systems.

Netscape's LiveWire server

This product included a JavaScript interpreter. Remember that when Netscape originally developed the JavaScript language, the original name was LiveScript. The language became known as JavaScript due to a marketing collaboration with Sun Microsystems where JavaScript was to be a kind of scripting language used with Java Applets in web pages. That went nowhere, but the name stuck.

The LiveWire server became later known as the Netscape Application Server, and is now known as the Oracle iPlanet Web Server.

See: ( JavaScript#Server-side_JavaScript

Microsoft's ASP server -- Internet Information Server

This product included Microsoft's JScript interpreter. JScript was released in 1996, as a reverse-engineered JavaScript implementation. JScript appeared in Internet Explorer 3, and was used in the Internet Information Server. Today JavaScript capabilities are included in the .NET server-side platform.


In addition to the above links:

( List_of_ECMAScript_engines

About the Author(s)

( David Herron : David Herron is a writer and software engineer focusing on the wise use of technology. He is especially interested in clean energy technologies like solar power, wind power, and electric cars. David worked for nearly 30 years in Silicon Valley on software ranging from electronic mail systems, to video streaming, to the Java programming language, and has published several books on Node.js programming and electric vehicles.

Books by David Herron