LinuxCommandLibrary

just-js

Run JavaScript without Node.js

TLDR

Start a REPL (interactive shell)

$ just
copy


Run a JavaScript file
$ just [path/to/file.js]
copy


Evaluate JavaScript code by passing it as an argument
$ just eval "[code]"
copy


Initialize a new project in a directory of the same name
$ just init [project_name]
copy


Build a JavaScript application into an executable
$ just build [path/to/file.js] --static
copy

SYNOPSIS

just-js [OPTIONS] [SCRIPT_FILE] [SCRIPT_ARGUMENTS...]
just-js -e | --eval JS_CODE

PARAMETERS

-h, --help
    Displays a help message with available options for the interpreter.

-v, --version
    Outputs the version information of the just-js interpreter.

-e <js_code>, --eval <js_code>
    Executes the provided JavaScript code string directly from the command line.

<script_file>
    The path to the JavaScript file to be executed by the interpreter.

[SCRIPT_ARGUMENTS...]
    Additional arguments passed directly to the executed JavaScript script. These are typically accessible within the script via a global array (e.g., scriptArgs or argv).

DESCRIPTION

just-js is a lightweight, barebones JavaScript interpreter designed for executing standalone JavaScript files and inline code snippets directly from the command line. Unlike larger runtimes such as Node.js or Deno, just-js focuses on providing a minimal environment, often leveraging embeddable engines like QuickJS or Duktape. This makes it ideal for shell scripting, quick utility tasks, and environments where resource efficiency and a small footprint are paramount. It typically lacks built-in modules for network, file system, or complex system interactions, concentrating solely on core JavaScript execution. Its simplicity allows for rapid startup times and minimal overhead, making it a valuable tool for automating simple tasks or processing data with JavaScript without the need for a full-fledged development environment. Due to its minimalist nature, just-js implementations can vary, often being custom scripts or wrappers built for specific purposes.

CAVEATS

just-js is often a custom implementation or a wrapper around an embedded JavaScript engine (e.g., QuickJS, Duktape). As such, its exact features, available global objects, and command-line options can vary significantly. It typically does not provide the extensive API surface found in Node.js (e.g., require, fs, http modules) or browser environments. It is primarily for core JavaScript execution and simple scripting tasks. Users should verify the specific capabilities of their just-js distribution, as there is no single standardized implementation.

TARGET AUDIENCE

Primarily aimed at developers and system administrators who require a lightweight, fast-starting JavaScript interpreter for shell scripts, automation, or simple data processing tasks without the overhead or feature set of larger JavaScript runtimes.

CORE FUNCTIONALITY

Its core functionality is limited to executing standard ECMAScript code. Any advanced features like network requests, file system access beyond basic standard I/O, or module loading mechanisms are typically absent unless explicitly compiled or scripted into a specific just-js implementation.

HISTORY

The concept behind just-js stems from the desire for highly portable and low-overhead JavaScript execution environments, distinct from large runtimes like Node.js. It reflects the increasing utility of JavaScript as a general-purpose scripting language for tasks traditionally handled by Bash or Python. While no single, canonical just-js project exists, the name likely refers to simple wrappers or direct executables built using embeddable JavaScript engines such as QuickJS (developed by Fabrice Bellard) or Duktape. These engines allow developers to embed a JavaScript runtime into their applications or create standalone command-line interpreters with minimal dependencies, catering to needs in embedded systems, command-line tooling, or rapid prototyping. The usage of "just-js" as a command name often signifies a highly focused, purpose-built JavaScript executor.

SEE ALSO

node(1), deno(1), js(1), just(1)

Copied to clipboard