Run script auto-detect package manager: npm, yarn, pnpm, bun, upm
- 🔍 Auto-detect the package manager:
npm,yarn,pnpm,bunandupm - 🔎 Search scripts by name or description in an interactive picker
- 🔁 Rerun the last script of a project with
nr - - 🗂️ Monorepo support: pick a workspace package, then a script
- 📝 Script descriptions shown in the picker
- 🧩 Usable as a library too
npm install -g run-script-cliRequires Node.js 18+.
# Pick a script to run (type to filter by name or description)
nr
# Run a specific script
nr dev
# Pass extra args to the script (`--` is added automatically for npm)
nr dev --port 3000
# Rerun the last script of this project
nr -
nr - --port 3000The last script is remembered per project and preselected the next time you run nr.
# Install dependencies
ni
# Add packages
ni react
ni -D vitestInstalls exactly what is in the lockfile, useful for CI.
ncinu reactnlx cowsay hello| Command | npm | yarn | pnpm | bun | upm |
|---|---|---|---|---|---|
nr dev |
npm run dev |
yarn run dev |
pnpm run dev |
bun run dev |
upm run dev |
ni |
npm install |
yarn install |
pnpm install |
bun install |
upm install |
ni react |
npm install react |
yarn add react |
pnpm add react |
bun add react |
upm add react |
nci |
npm ci |
yarn install --frozen-lockfile |
pnpm install --frozen-lockfile |
bun install --frozen-lockfile |
upm install --frozen-lockfile |
nu react |
npm uninstall react |
yarn remove react |
pnpm remove react |
bun remove react |
upm remove react |
nlx cowsay |
npx cowsay |
npx cowsay |
pnpm dlx cowsay |
bunx cowsay |
upx cowsay |
Starting from the current directory and walking up to the root, the first match wins:
- The
packageManagerfield inpackage.json(e.g."packageManager": "pnpm@9.0.0") - A lockfile:
| Lockfile | Package manager |
|---|---|
upm.lock |
upm |
bun.lock, bun.lockb |
bun |
pnpm-lock.yaml |
pnpm |
yarn.lock |
yarn |
package-lock.json, npm-shrinkwrap.json |
npm |
If nothing is found, you'll be asked to choose one.
Use -w (or --workspace) to pick a workspace package first, then a script. The script runs inside that package's directory.
# Pick a package, then a script
nr -w
# Pick a package, then run its `build` script
nr -w buildWorkspaces are read from pnpm-workspace.yaml or the workspaces field in package.json. Patterns like packages/*, packages/** and !packages/ignored are supported.
By default the picker shows each script's command. You can show a description instead, in either of two ways:
{
"scripts": {
"?dev": "Start the dev server",
"dev": "vite",
},
}import { detectAgent, getCommand, findWorkspaceRoot, getWorkspacePackages } from 'run-script-cli';
detectAgent(process.cwd()); // 'npm' | 'yarn' | 'pnpm' | 'bun' | 'upm' | undefined
getCommand('pnpm', 'add', ['react']); // ['pnpm', 'add', 'react']
getCommand('npm', 'run', ['dev', '--port', '3000']); // ['npm', 'run', 'dev', '--', '--port', '3000']
const root = findWorkspaceRoot(process.cwd());
if (root) {
getWorkspacePackages(root); // [{ name, dir, path }, ...]
}Available commands for getCommand: run, install, frozen, add, remove, execute.
pnpm install
pnpm build # build to dist/
pnpm test # run tests
pnpm lint # type check
{ "scripts": { "dev": "vite", "build": "vite build", }, "scripts-info": { "dev": "Start the dev server", "build": "Build for production", }, }