execa
Execa is a modern library for running external commands and scripts in Node.js, providing a better API than Node.js's built-in child_process module. Execa impro…
Installation
npm install execa
yarn add execa
pnpm add execa
Import
import { execa } from 'execa';Quick Example
import { execa } from 'execa';
const { stdout } = await execa('git', ['log', '--oneline', '-5']);
console.log(stdout);
// With shell
const { stdout: files } = await execa({ shell: true })`ls -la | grep .ts`;
// Error handling
try {
await execa('unknown-command');
} catch (error) {
console.log(error.shortMessage);
}About execa
Execa is a modern library for running external commands and scripts in Node.js, providing a better API than Node.js's built-in child_process module. Execa improves upon child_process with Promise-based execution, automatic output parsing, better error messages that include the command, exit code, stderr, and stdout in a single error object, cross-platform command resolution, and sensible defaults. The library strips final newlines from output, resolves locally installed binaries from node_modules/.bin, supports piping between commands, and provides both string and array-based command specification. Execa handles shell scripts with the shell option, stdin/stdout/stderr configuration with inherit/pipe/ignore options, timeouts, signal-based cancellation through AbortController, IPC messaging with child processes, and streaming for real-time output processing. The verbose option logs commands as they execute, useful for debugging build scripts. Execa's error objects include the full context needed for debugging — command, exit code, signal, stdout, stderr, and whether the process timed out or was killed. The library is widely used in build tools, CLI applications, and test suites that need to spawn and manage child processes. Execa has become the standard way to run external commands in modern Node.js codebases.
Quick Facts
| Package | execa |
| Category | File System |
| Weekly Downloads | 15M+ |
| License | MIT |
| Install | npm install execa |
Related Packages
fs-extra is a drop-in replacement for Node.js's built-in fs module that adds additional file system …
Chokidar is a fast, efficient file watching library for Node.js that provides a reliable cross-platf…
Concurrently is a utility for running multiple commands simultaneously in a single terminal, with ea…
Nodemon is a utility that monitors for file changes in your Node.js application and automatically re…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.