Skip to main content
QuickJS runs node and js: a bare ES2023 engine in WebAssembly, inside the Mirage process, for small scripts and pipe transforms. It is not Node: there is no require, npm, fs or fetch. The files it opens are the workspace’s, under the same mount modes and permissions as shell commands. It is in the default runtimes of both SDKs.

Installation

Download qjs-wasi.wasm from a quickjs-ng release. Point home, or MIRAGE_QUICKJS_HOME, at its directory.

Usage

QuickJS is in the default runtimes, so node works once it is installed. To list it yourself:

What is wired

std and os are globals, as in qjs --std. In TypeScript, any std or os function not listed as supported throws TypeError.

Notes

  • -e <code> runs the argument, a file runs a mounted script, and with neither, piped input is the program. A .mjs file runs as an ES module; .js and -e run as classic scripts, and -m forces module mode.
  • console.log and print add a newline; std.out.puts and std.err.puts write raw.
  • QuickJS cannot reach host files or the network, but only command_limits bound its CPU and memory. Run untrusted or heavy code in a sandbox.
  • QuickJS can evaluate expressions, so it can run a route policy: route_policy: ./policy.js runs per line with ctx as a global, and the last expression names the runtime.