1. License
“to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software”
MIT allows use in paid and closed-source products.
github.com/moxystudio/node-cross-spawn/blob/master/LICENSE2. Maintained
github.com/moxystudio/node-cross-spawn3. Used by agents' projects
Dependency in 8 public GitHub projects set up for AI coding agents that we scanned (0.1%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error
What cross-spawn does
cross-spawn is a small free library for Node.js programs that start other programs, like npm, git or a build script. On Mac and Linux it changes nothing. On Windows it finds the right file, adds the escaping that Windows needs and runs scripts that start with a "#!" line, so the same code works everywhere.
What people build with it
Run npm scripts from your tool
Your setup or build script calls "npm install" or "npm run build". On Windows npm is a .cmd file that a plain start call cannot find; cross-spawn finds and runs it.
Pass awkward arguments safely
A commit message with an ampersand, or a lint rule with quotes and brackets, reaches the other program exactly as you wrote it, also on Windows.
Start scripts that use a "#!" line
Your project has helper scripts that begin with "#!/usr/bin/env node". Windows does not read that line; cross-spawn does and starts the script with node.
A command line tool for every system
You publish a small developer tool that starts git, npm or a compiler. It behaves the same for users on Windows as on a Mac.
Agent tools that run commands Idea
Your AI agent's "run a command" tool gets a program name and its arguments from the model. It starts them without a shell, so the tool also works on Windows.
cross-spawn popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How cross-spawn is used
- cross-spawn is a dependency in 8 of the 6,258 public GitHub projects set up for AI coding agents that we scanned, too few to describe it from them alone. Our scan also samples projects by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750); counting those, it appears in 46 projects, and what it is used with below comes from all of them.
- The most used alternative in our scan is concurrently (484 projects).
- Projects that use it most often also use Model Context Protocol SDK (JavaScript) (41.3%), ws (39.1%), Axios (34.8%).
Often used with
More about cross-spawn
More in Dev workflow and config
Alternatives
cross-spawn This page
Pick execa when you want promises, captured output and nicer errors on top of starting programs, with its own Windows handling.
Pick zx when you are writing a whole shell-style script in JavaScript rather than starting one program from your code.
Pick ShellJS when you need Unix commands like cp, rm or grep themselves to work on Windows, not other programs started.
Run multiple npm scripts concurrently for efficient development workflows.
Get started
Tell your AI assistant
“Use the npm package cross-spawn (pin cross-spawn@7.0.6) instead of child_process.spawn to start npm and git from this Node.js script; pass the arguments as an array, do not set shell: true, and check result.error and result.status.”
Add cross-spawn to your Node.js project (Node.js 8 or newer).
npm install cross-spawnFrom github.com/moxystudio/node-cross-spawn/blob/master/README.md
Use it exactly like Node's own spawn and spawnSync; only the import changes.
const spawn = require('cross-spawn'); // Spawn NPM asynchronously const child = spawn('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' }); // Spawn NPM synchronously const result = spawn.sync('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });From github.com/moxystudio/node-cross-spawn/blob/master/README.md
Mistakes to avoid
Older versions have a known slow-down bug (CVE-2024-21538) triggered by crafted long text.
With shell on, cross-spawn does no escaping, and hand-escaping user input is error prone.
On Windows npm is a .cmd file, and Node's own docs say .cmd and .bat files cannot be launched with execFile.
It is a drop-in for Node's spawn, so it returns a child process object, not a promise.
Questions
Does it change anything on Mac or Linux?
No. The extra work only happens on Windows; elsewhere your call goes to Node's spawn unchanged, as our run shows.
Why not just use shell true in Node's spawn?
Then you have to escape the command and arguments yourself, which is easy to get wrong, especially with user input.
Which version do I need for an old Node.js?
Version 7 needs Node.js 8 or newer; for Node.js 7 and older the README points to version 6.
Can I use it in a commercial product?
Yes. It is MIT-licensed; keep the license notice with copies of its files.