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
pm run <script> [...args]
Arguments
script string required
The name of the script to run from package.json
args string[]
Additional arguments to pass to the script
Examples
Run Build Script
pm run build
Running: pnpm run build
Run Test Script
pm run test
Running: pnpm run test
Run Script with Arguments
pm run test -- --watch
Running: pnpm run test -- --watch
Run Custom Script
pm run dev
Running: pnpm run dev
Package.json Scripts
Define scripts in your package.json:
{
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"test": "vitest",
"lint": "eslint ."
}
}
Then run them with:
pm run dev
pm run build
pm run test
pm run lint
How It Works
From src/commands/run.ts:14:
const cmd = ShellCommand.make(pm.name, 'run', ...passthrough);
yield* Console.log(`Running: ${pm.name} run ${passthrough.join(' ')}`);
yield* runShellCommand(cmd);
The command:
- Detects your project’s package manager
- Passes all arguments directly to
<pm> run - 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> |
Common Scripts
Typical scripts you might run:
dev- Start development serverbuild- Build for productiontest- Run testslint- Run linterformat- Format codetypecheck- Run TypeScript type checkingpreview- Preview production build
Related Commands
- pm x - Execute packages without installing
- pm install - Install dependencies