📂
File System15M+/wkMIT

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
npm install execa
yarn
yarn add execa
pnpm
pnpm add execa

Import

ESM
import { execa } from 'execa';

Quick Example

usage
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

Packageexeca
CategoryFile System
Weekly Downloads15M+
LicenseMIT
Installnpm install execa

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.