Skip to main content

Running Code

RunJS executes the code in the active tab and displays the results in the output pane. There's no project setup, no build step, and no config needed — open a tab, write code, and run it.

Auto Run and manual runs

By default, RunJS evaluates your code as you type. Each keystroke triggers a fresh execution and the output pane updates in place, which makes it well suited to interactive exploration.

If you'd rather run code on demand, disable Auto Run under Settings → General. With Auto Run off, you trigger execution explicitly:

  • The run button in the activity bar
  • The keyboard shortcut for Run (Cmd+R on macOS, Ctrl+R on Windows and Linux)

A run can also be cancelled mid-execution with Stop (Cmd+Shift+R / Ctrl+Shift+R), which is useful for long-running async work or accidental long loops.

Runtime environments

Each tab runs in one of three environments. Set the default for new tabs under Settings → General, or change the environment for the current tab from the status bar.

Browser & Node.js — The default. Globals from both worlds are available, so you can use fetch, URL, and other Web APIs alongside Node built-ins like fs, path, and process. This is the most flexible choice and a good fit for the majority of one-off scripts.

Node.js — Code runs as if it were a Node script. Use this when you specifically want Node behaviour — the require resolution algorithm, full access to Node's standard library, and no DOM globals to confuse autocomplete.

Browser — Code runs against browser-style globals only. Use this for code intended to ship to a web page, where relying on a Node API by accident would be a problem.

Switching environments doesn't change the code you write; it changes which globals and APIs are available at runtime and which type definitions feed autocomplete and linting.

Language support

RunJS supports four languages, selectable per tab from the status bar. Set the default for new tabs under Settings → General.

JavaScript — Plain ECMAScript. Modern syntax including ES modules, top-level await, optional chaining, and nullish coalescing all work without configuration.

TypeScript — Code is type-checked by the TypeScript language service and compiled to JavaScript before it runs. Type errors show up inline in the editor (when Linting is enabled in Settings → Editor), but they don't block execution — RunJS will still run the compiled output, so you can iterate quickly without fixing every diagnostic first.

JSX — JavaScript with JSX syntax. JSX expressions are transpiled before execution.

TSX — TypeScript with JSX syntax. Combines TypeScript's type checking with JSX support.

For TypeScript and TSX, types from installed npm packages — whether bundled or pulled from @types/* — feed both autocomplete and the inline type checker.

Imports and modules

Both ES modules and CommonJS are supported. Use whichever style you prefer:

import { readFile } from 'node:fs/promises'
// or
const { readFile } = require('node:fs/promises')

Third-party packages installed through the NPM Packages tool are resolvable by name, exactly as they would be in a regular Node project.

Working directory

You can set a working directory for a tab from the Actions menu. Once set, relative paths in import, require, and Node fs operations resolve against it:

import helper from './lib/helper.js'

Async code

Top-level await works in every language, so you can drop into asynchronous APIs without wrapping everything in an async function:

const response = await fetch('https://api.example.com/data')
const data = await response.json()
data

Promises that reject without being caught surface as errors in the output pane, the same as a synchronous throw.