Execa runs commands in your script, application or library. Unlike shells, it is optimized for programmatic usage. Built on top of the child_process core module.
const {stdout, pipedFrom} = await execa`npm run build`
.pipe`sort`
.pipe`head -n 2`;
// Output of `npm run build | sort | head -n 2`console.log(stdout);
// Output of `npm run build | sort`console.log(pipedFrom[0].stdout);
// Output of `npm run build`console.log(pipedFrom[0].pipedFrom[0].stdout);
// Similar to: npm run build < input.txtawaitexeca({stdin: {file: 'input.txt'}})`npm run build`;
File output
// Similar to: npm run build > output.txtawaitexeca({stdout: {file: 'output.txt'}})`npm run build`;
Split into text lines
const {stdout} = awaitexeca({lines: true})`npm run build`;
// Print first 10 linesconsole.log(stdout.slice(0, 10).join('\n'));
Streaming
Iterate over text lines
forawait (const line of execa`npm run build`) {
if (line.includes('WARN')) {
console.warn(line);
}
}
Transform/filter output
let count = 0;
// Filter out secret lines, then prepend the line numberconst transform = function * (line) {
if (!line.includes('secret')) {
yield`[${count++}] ${line}`;
}
};
awaitexeca({stdout: transform})`npm run build`;
ShellJS is a portable Unix shell commands implementation for Node.js. It offers a higher-level API for executing commands but does not support returning promises natively.
Cross-spawn is a cross-platform solution for spawning child processes. It aims to solve compatibility issues on Windows but does not provide a promise-based API.
The npm package execa receives a total of 99,711,937 weekly downloads. As such, execa popularity was classified as popular.
We found that execa demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 2 open source maintainers collaborating on the project.
Package last updated on 29 Nov 2025
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.