userland.run70Try the demo
Catalog app · RISC-V VM · runs on Node.js

Run prettier in the browser

Format JavaScript, TypeScript, CSS, JSON, Markdown and more with the real Prettier.

Try it live

Nothing is downloaded until you press Run.

catalog app

Format a file with Prettier on the RISC-V Node.js

Installs the RISC-V node and the Prettier tree from the signed catalog, then runs Prettier's CLI with /usr/bin/node on the emulator (1.8 GB guest).

bash
/usr/bin/node /usr/local/lib/node_modules/prettier/bin/prettier.cjs --version
/usr/bin/node /usr/local/lib/node_modules/prettier/bin/prettier.cjs app.js
loading…
Expected output
$ /usr/bin/node /usr/local/lib/node_modules/prettier/bin/prettier.cjs --version
3.8.1
$ /usr/bin/node /usr/local/lib/node_modules/prettier/bin/prettier.cjs app.js
const greet = (name) => {
  return "hello, " + name;
};
console.log(greet("nano"));

What it is

Prettier reprints source code in one consistent style, so formatting stops being a review topic. The catalog package is the unmodified Prettier 3 npm tree under /usr/local/lib/node_modules and needs a Node.js runtime. On NanoVM it runs on the catalog's RISC-V Node.js and produces the same output as a local run.

Package facts

version
3.8.1
runs on
RISC-V VM (elf-app, riscv64gc-linux-musl)
download
2.2 MB compressed · 57 files
command
prettier
requires
node
license
MIT (upstream)
upstream
github.com/prettier/prettier
collections
Node dev toolchain
catalog
generation 12, Ed25519-signed

Install and run it from your page

With the SDK, installApp resolves prettier in the signed index, fetches its content-addressed chunks from the CDN, verifies each one and writes the files into the VM. It is a JavaScript program, so it needs a Node.js runtime: install the catalog's node and run it on the RISC-V VM, or run its entry script with nano.node() on the host JavaScript engine where that engine supports it. Details in Installing catalog apps.

javascript
import { createNano } from "@userland-run/nano-sdk";

// JS tools run on the RISC-V node: keep the default ~1.8 GB guest.
const nano = await createNano({ image: { wasm: "/nano/console.wasm" } });
await nano.installApp("node");
await nano.installApp("prettier"); // signature-verified, cached in OPFS

const r = await nano.shExec("/usr/bin/node /usr/local/lib/node_modules/prettier/bin/prettier.cjs --version");
console.log(r.stdout);

Typical usage of the upstream command-line tool:

bash
prettier --write .

Caveats

← All 32 catalog apps