> ## Documentation Index
> Fetch the complete documentation index at: https://better-pm.fdarian.com/llms.txt
> Use this file to discover all available pages before exploring further.

# pm run

> Run package.json scripts

## Overview

The `pm run` command executes scripts defined in your `package.json` file. It's a simple passthrough to your package manager's run command.

## Syntax

```bash theme={null}
pm run <script> [...args]
```

## Arguments

<ParamField path="script" type="string" required>
  The name of the script to run from package.json
</ParamField>

<ParamField path="args" type="string[]">
  Additional arguments to pass to the script
</ParamField>

## Examples

### Run Build Script

```bash theme={null}
pm run build
```

```bash Output theme={null}
Running: pnpm run build
```

### Run Test Script

```bash theme={null}
pm run test
```

```bash Output theme={null}
Running: pnpm run test
```

### Run Script with Arguments

```bash theme={null}
pm run test -- --watch
```

```bash Output theme={null}
Running: pnpm run test -- --watch
```

### Run Custom Script

```bash theme={null}
pm run dev
```

```bash Output theme={null}
Running: pnpm run dev
```

## Package.json Scripts

Define scripts in your `package.json`:

```json package.json theme={null}
{
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "test": "vitest",
    "lint": "eslint ."
  }
}
```

Then run them with:

```bash theme={null}
pm run dev
pm run build
pm run test
pm run lint
```

## How It Works

From `src/commands/run.ts:14`:

```typescript theme={null}
const cmd = ShellCommand.make(pm.name, 'run', ...passthrough);
yield* Console.log(`Running: ${pm.name} run ${passthrough.join(' ')}`);
yield* runShellCommand(cmd);
```

The command:

1. Detects your project's package manager
2. Passes all arguments directly to `<pm> run`
3. Executes the command with the script and any additional arguments

## Package Manager Compatibility

| Package Manager | Command             |
| --------------- | ------------------- |
| pnpm            | `pnpm run <script>` |
| bun             | `bun run <script>`  |
| npm             | `npm run <script>`  |

<Tip>
  All package managers support the `run` command, making this a universal way to execute scripts.
</Tip>

## Common Scripts

Typical scripts you might run:

* `dev` - Start development server
* `build` - Build for production
* `test` - Run tests
* `lint` - Run linter
* `format` - Format code
* `typecheck` - Run TypeScript type checking
* `preview` - Preview production build

## Related Commands

* [pm x](/commands/x) - Execute packages without installing
* [pm install](/commands/install) - Install dependencies
