Skip to content

Getting started

Installation

Install unrun using your preferred package manager:

sh
npm install unrun
sh
pnpm add unrun
sh
yarn add unrun
sh
bun add unrun

Usage

CLI

You can use unrun via the command line interface (CLI) to run a JavaScript or TypeScript file directly.

sh
npx unrun ./path/to/file.ts
sh
pnpx unrun ./path/to/file.ts
sh
yarn dlx unrun ./path/to/file.ts

Programmatic API

You can also use unrun programmatically in your code, either asynchronously or synchronously.

  • Async usage
ts
import { unrun } from 'unrun'

const { module } = await unrun({
  path: './path/to/file.ts', // Path to the module to load
})
  • Sync usage
ts
import { unrunSync } from 'unrun'

const { module } = unrunSync({
  path: './path/to/file.ts', // Path to the module to load
})

WARNING

The synchronous API requires synckit to be installed. If you don't have it installed, please run npm install synckit or the equivalent command for your package manager.