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

Programmatic API

You can use unrun both asynchronously and synchronously to load and execute modules.

  • 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.

CLI

You can also 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