Getting started
Installation
Install unrun using your preferred package manager:
sh
npm install unrunsh
pnpm add unrunsh
yarn add unrunsh
bun add unrunUsage
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.tssh
pnpx unrun ./path/to/file.tssh
yarn dlx unrun ./path/to/file.ts