# execa — card for AI agents

Execute external processes with a better API and error handling for Node.js.

Category: Utilities · npm package `execa` · latest version 10.2.1 (checked 2026-11-01)
Install: `npm install execa`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 70.9 (#344 of all tools, 34 of 408 in its category)
- Used in 46 public projects set up for AI coding agents (0.7%)
- Downloads last week: 245,361,651 (as of 2026-11-24), +39.3% over 4 weeks
- GitHub stars: 7,666 (as of 2026-11-24)
- Last push: 2026-11-18

## Often used with
tsx 78.3%, chalk 69.6%, Zod 78.3%, Anthropic SDK 56.5%, Commander 54.3%, dotenv 54.3%

## Links
- AgentGid page: https://agentgid.com/tools/execa/
- Homepage: https://github.com/sindresorhus/execa#readme
- Repository: https://github.com/sindresorhus/execa


## execa: run other programs from Node.js code

execa is a free JavaScript package that lets a Node.js script or server start other programs, such as git, ffmpeg or a build command, and read what they print. Each piece of text, like a file name a user typed, reaches the program as one separate value, so it cannot sneak in a second command. It runs only on a server or your own computer, not in a web page.

### Where to use it
- Build and deploy scripts: A release script in JavaScript runs the build, reads the current git branch and starts the deploy, one step after another.
- Process a file a user uploaded: Your server calls an image or video tool on a file whose name came from a user; the name stays one value even if it holds spaces or a semicolon.
- Stop a command that hangs: A tool your AI agent or job queue starts sometimes never ends; give it a time limit and report a clear timeout.
- Show clear errors when a step fails: When a command fails, your log shows the command, its exit code and what it printed, instead of a bare crash.
- Watch warnings while a build runs: Read a long command's output line by line and react to each warning as it appears, not only at the end.
- Run project tools without npx: A script calls a tool installed in the project, such as a linter, without a global install.

### How to start
- Add execa to your Node.js project (version 10 needs Node.js 22 or newer).

```
npm install execa
```

- Import it and run a command with the template syntax; spaces split the command into the program and its arguments.

```
import {execa} from 'execa';

const {stdout} = await execa`npm run build`;
// Print command's output
console.log(stdout);
```


### License
Free to use, also in paid and closed products, under the MIT license. Keep the license notice when you copy or ship its files; no visible credit is needed.

### Good to know
- Version 10 needs Node.js 22 or newer. On older Node.js, stay on version 9.
- It does not use a shell unless you ask for one. Pipes, redirects and wildcards like *.txt then have no special meaning.
- If you switch the shell on, the safety goes away; your code must quote every value itself.
- The package is fairly large; the authors point to a smaller sibling package, nano-spawn, for libraries and serverless functions.
- The project is active; version 10.2.1 came out on 23 October 2026.

Checked 2026-11-11 against: https://github.com/sindresorhus/execa/blob/main/readme.md, https://github.com/sindresorhus/execa/blob/main/docs/escaping.md, https://github.com/sindresorhus/execa/blob/main/docs/shell.md, https://github.com/sindresorhus/execa/blob/main/docs/errors.md, https://github.com/sindresorhus/execa/blob/main/docs/termination.md, https://github.com/sindresorhus/execa/blob/main/docs/small.md, https://github.com/sindresorhus/execa/blob/main/docs/bash.md, https://github.com/sindresorhus/execa/blob/main/docs/execution.md, https://github.com/sindresorhus/execa/blob/main/package.json, https://github.com/sindresorhus/execa/blob/main/license, https://github.com/sindresorhus/execa/releases/tag/v10.0.0, https://registry.npmjs.org/execa

### Mistakes to avoid
- Don't: await execaCommand('npm run build') → Do: await execa`npm run build` (or execa`${parseCommandString(commandString)}` for a dynamic string) (execaCommand() and execaCommandSync() were removed in execa 10.)
- Don't: subprocess.on('spawn', onSpawn) → Do: subprocess.nodeChildProcess.on('spawn', onSpawn) (Since execa 10 the subprocess is a plain promise; Node's ChildProcess methods moved to subprocess.nodeChildProcess.)
- Don't: await execa({shell: true})`convert ${userFileName} out.jpg` → Do: Leave shell off and pass the value with ${} or in the arguments array (With the shell on, execa stops escaping arguments, so a name like 'a.png; rm -rf ~' runs a second command.)
- Don't: execa`echo $HOME` or execa`ls *.txt` expecting the shell to expand them → Do: Read process.env.HOME or list files in JavaScript, then pass the values as arguments (No shell runs, so $VAR, *, | and && are passed as plain text.)
- Don't: npm install execa on Node.js 18 or 20 → Do: Use Node.js 22+, or pin execa@9 on older Node.js (execa 10 declares engines node >=22.)

### Questions
- Is it safe to put a user's file name into a command? Yes, as long as you pass it with ${} or in the arguments array and do not switch the shell on; it then reaches the program as one argument.
- Does it work in the browser? No. It is built on Node's child_process module, so it runs in Node.js on a server or your computer.
- Where did execaCommand() go? Version 10 removed execaCommand() and execaCommandSync(). Use the template syntax, or parseCommandString() for a command held in one string.
- How do I know why a command failed? The error carries the exit code and flags such as timedOut, isCanceled and isMaxBuffer.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
