mrkeyoor.comAsk

google/zxtested 23 Nov 2026commit 3b04a6a

zx review

Use zx when familiar JavaScript simplifies scripts combining shell commands with JSON or API calls, and your team can specify the shell and external executables.

  • README install 2.1 s
  • README snippet failed
12 sto install
  • 976 KB on disk
  • 0 dependencies
Dev Toolsevaluationupdated 23 Nov 2026
+8stars / 7d

Google's zx provides JavaScript command templates around Node's child_process API, escapes interpolated arguments and supplies defaults for process execution. The README lists Bash or PowerShell, CommonJS and ECMAScript modules, and Apache-2.0 licensing. It says zx is not an officially supported Google product.

Verdict

Use zx when familiar JavaScript simplifies scripts combining shell commands with JSON or API calls, and your team can specify the shell and external executables. Keep Bash when the existing script is clearer. Teams requiring Bash commands to work unchanged in PowerShell should not choose zx on that assumption. Our source checkout installed in 12 seconds and built in 13 seconds, then tests failed after 47 seconds; the separate zx 8.8.5 quickstart installed successfully but its node-launched README snippet stopped at parsing.

We ran it

Lab card: what happened when we ran zx
Lab card from our sandbox run
Screenshot of zx (google.github.io/zx)
google.github.io/zx
Install✓ · 12s502 packages · 266 MB
Build✓ · 13s
Tests✗ · 47sran, no count parsed
Known vulns00 critical · 0 high · 0 moderate · 0 low (npm audit)
Repo182 files~37,214 lines of source · 1.8 MB · 8 CI workflows · tests dir

Answers from our run

Does zx build from source?

Dependencies installed in 12 seconds (502 packages), and the build succeeded in 13 seconds. We cloned commit 3b04a6a into a clean Debian container with 3 CPUs and no project-specific setup.

Do zx's tests pass?

No. The project's own test command exited unsuccessfully after 47 seconds, and its output did not expose an individual test count.

Does zx have known vulnerabilities in its dependencies?

npm audit found none in the dependency tree at the time of our run.

Who should not use zx?

Teams expecting Bash commands to work unchanged in PowerShell: issue #523 reports PowerShell rejecting the -rf parameter.

What are the alternatives to zx?

Bash, Node.js child_process, PowerShell. Use zx when familiar JavaScript simplifies scripts combining shell commands with JSON or API calls, and your team can specify the shell and external executables.

Setup3/5In our 2026-11-23 run it installed as the README says in 2.1 s, but the README’s “(intro)” example failed as written with “SyntaxError: await is only valid in async functions and the top level…”.Editor’s note: Source installation and build succeeded, but tests failed and the separate quickstart stopped at parsing; neither run demonstrates completed script setup.
Docs3/5The README has an install section (“Install”) and a usage section (“Usage”), but its “(intro)” example failed as written in our 2026-11-23 run (“SyntaxError: await is only valid in async functions and the top level…”).Editor’s note: The readable guides document launch routes, shell helpers and module formats, but these extracts do not support a numerical documentation assessment.
Community5/5Last push on 2026-11-05, 45,865 stars and maintainers answered or closed 10 of the 10 most-discussed issues we sampled.Editor’s note: Authors describe useful workflows and issues contain maintainer replies; these samples do not measure response times or adoption.
Maturity3/5Latest release 8.8.5 on 2025-10-19, repository created 2021-05-05 and its test suite did not pass in our sandbox.Editor’s note: The source scan found eight CI workflows and tests, but the failed test command supplies no production-reliability assessment.

How we score

Discussed on

  1. hnJavaScript for Shell Scripting385 points
  2. hnZx 3.0189 points
  3. hnZX – A tool for writing better scripts162 points
  4. hnZx: A tool for writing better scritps4 points
  5. hnGoogle/Zx v8.13 points

Who it’s for

JavaScript developers combining shell commands with JSON handling or API calls.
Teams moving larger package.json commands into script files.
Maintainers who can specify their scripts' shell and external executables.

Who it’s NOT for

Teams expecting Bash commands to work unchanged in PowerShell: issue #523 reports PowerShell rejecting the -rf parameter.
Developers whose existing Bash scripts are already clearer, as Lakatos found for adding two command-line numbers.
Operators choosing zx as an assumed Ansible replacement: issue #247 describes an SSH-wrapper experiment and an author's aspiration.

Setup reality

Our November 23, 2026 source-checkout run at commit 3b04a6a installed in 12 seconds and built in 13 seconds. Tests exited 1 after 47 seconds. The tail included '4 subtests failed' and '2 subtests failed', alongside successful entries. The run recorded 502 dependencies, 266 MB on disk and 0 known npm audit vulnerabilities. Its sandbox configuration was 3 CPUs, 8 GB RAM and image label lab-node:22.

A separate quickstart used a fresh lab-node:22 container configured with 2 CPUs and 4 GB RAM. Cloning took 2 seconds. npm install zx@latest installed zx 8.8.5 in 2.1 seconds, occupied 976 KB in node_modules and installed 0 packages besides zx. Running the unedited 15-line introductory README block with node failed in 0.1 seconds with exit 1 and a top-level await syntax error. Teardown succeeded.

The getting-started guide documents .mjs files, the zx launcher and explicit globals imports. The setup extract documents shell-selection helpers and both CommonJS and ECMAScript module entry points.

The short answer: use JavaScript when the script needs it

Use google/zx when familiar JavaScript makes shell-command orchestration and JSON handling easier to maintain. Keep Bash when the existing script is clearer, and choose the shell your commands require. In issue #523, PowerShell rejected the -rf parameter in a shared script. Our source checkout installed in 12 seconds and built in 13 seconds, but its test command exited 1 after 47 seconds. Those are separate outcomes: installation and compilation succeeded before the test failure.

The getting-started guide describes zx's command template as returning a ProcessPromise. You retain recognizable command strings while using JavaScript for conditions, arrays and asynchronous sequencing. Lakatos's JSON example and Wargo's publishing workflow give concrete reasons to consider that arrangement. Their accounts also suggest a useful starting point: move a script because its data handling or coordination benefits from JavaScript, rather than treating every existing shell script as a rewrite candidate.

What Google's zx actually supplies

Google's zx wraps child_process, escapes arguments and provides defaults for running commands from JavaScript. The README describes those wrappers and lists Linux, macOS and Windows compatibility. Its requirements also include Bash or PowerShell: a JavaScript interface still launches commands through a shell. The same README lists JavaScript and TypeScript, CommonJS and ECMAScript modules, Apache-2.0 licensing, and the disclaimer that zx is not an officially supported Google product.

The README lists Node.js 12.20.0 or newer, Bun 1.0.0 or newer, Deno 1.x and 2.x, GraalVM Node.js, and Electron 11 or newer. These are documented compatibility statements. The separate quickstart installed npm package version 8.8.5, while the source-checkout measurements identify commit 3b04a6a. Keeping those identifiers beside their results distinguishes a package installation from the repository build and test procedure. The setup guide also documents both CJS and ESM entry points.

What people use zx for

Reported zx uses include fetching JSON, configuring Android devices and coordinating Eleventy publishing. Lakatos and Wargo describe scripts they wrote for those tasks, while Hacker News commenters describe project maintenance and workplace automation. Their accounts identify the surrounding tools as well as the JavaScript: a JSON endpoint for Lakatos, adb for Wargo's Android workflow, and publishing commands for his website. Those details explain what zx coordinates in each example.

Person and task What they did Outcome reported
Alex Lakatos, command-line puns Fetched JSON, selected a random pun and colored its output Reported a working command-line script after abandoning a similar shell implementation
John M. Wargo, Android setup Passed a Particle access token or device ID to an Android device through adb Consolidated his use cases into one script controlled by command-line options
John M. Wargo, Eleventy publishing Controlled publishing options, including Algolia indexing and package-version updates Put those choices behind a single command
A Hacker News commenter, project scripts Replaced a shell script involving file moves and a build Reported easier reading after time away, autocomplete and familiar APIs
A Hacker News commenter, workplace automation Used zx for tooling setup, CI and API response checks Reported that it worked well in an existing JavaScript workplace

Lakatos preferred Bash for adding two command-line numbers and JavaScript for parsing JSON. His comparison makes the difficult part of the task the deciding factor. Wargo's Android workflow adds a concrete dependency: its commands use adb to communicate with a connected device. His publishing workflow similarly coordinates other programs. A useful adoption question is therefore whether JavaScript improves the code around those commands, including options, data handling and execution order.

What happened when we ran it

Our source-checkout run installed in 12 seconds and built in 13 seconds, but the test command exited 1 after 47 seconds. We measured commit 3b04a6a on November 23, 2026, with a recorded configuration of 3 CPUs, 8 GB RAM and image label lab-node:22. The source-checkout measurements record 502 dependencies and 266 MB on disk. A separate npm quickstart used a different installation procedure and a smaller configured container.

Source-checkout check Recorded result
npm install Succeeded in 12 seconds
Build Succeeded in 13 seconds
Tests Failed after 47 seconds, exit 1
Dependencies 502 recorded, 266 MB on disk
npm audit 0 known vulnerabilities: 0 critical, 0 high, 0 moderate, 0 low
Repository scan 182 files, approximately 37,214 source lines, 1.8 MB checked out
Development signals 8 CI workflow files, a tests directory, no Dockerfile detected

The failing test tail contains successful ok entries for error, core, cli, index, global, goods, another index entry, transformMarkdown(), util and vendor API. It also contains the nested summaries '4 subtests failed' and '2 subtests failed'. Installation and compilation completed before the failed test command. Reporting the entries and summaries separately preserves what the log actually shows without turning nested failures into an invented overall test count.

The separate quickstart ran in a fresh container configured with 2 CPUs and 4 GB RAM, with no published ports or secrets. It recorded source commit 3b04a6ae3e34 and installed the npm package through zx@latest, which resolved to 8.8.5. Its task was the unedited 15-line introductory README block, launched with node. The recorded steps include package installation, the unsuccessful snippet launch and successful cleanup.

Quickstart check Recorded result
Clone Completed in 2 seconds
Package installation npm install zx@latest installed zx 8.8.5 in 2.1 seconds
Installed size 976 KB in node_modules
Additional dependencies 0 packages besides zx installed
README snippet launch Unedited 15-line block run with node; failed in 0.1 seconds, exit 1
Recorded finding snippet-failed: top-level await syntax error
Teardown Succeeded

The snippet produced the error “SyntaxError: await is only valid in async functions and the top level bodies of modules”. The getting-started guide instructs readers to use .mjs for top-level await, shows zx ./script.mjs, and documents an explicit zx/globals import. These are documented launch instructions, distinct from the recorded node attempt. That attempt stopped at JavaScript parsing before completing the introductory command sequence.

Where people get stuck: quoting, shells and modules

Historical zx reports describe quoting trouble in version 2, extra dollar signs in 7.0.4 and 7.0.5, and module-resolution failures after an upgrade to 6.0.7. The version numbers make those reports useful troubleshooting references. They concern different layers of a script: values becoming shell arguments, the shell accepting command options, and a module resolver finding the package. Matching an error to the right layer is more useful than treating every report as the same compatibility problem.

Report What went wrong What the discussion supports
apibrac in #164, zx 2 Added shell quotes around interpolations disrupted a gcloud log filter The maintainer advised moving the whole argument into a JavaScript variable
#471, zx 7.0.4 and 7.0.5 A value containing a colon gained an extra dollar sign The report compares working 7.0.3 behavior with the later versions
budarin and louisgv in #523 PowerShell rejected -rf; selecting Bash then exposed a WSL versus Git Bash distinction budarin reported that zx@dev worked; louisgv described separate filesystem and path behavior
borkdude in #382, 5.3.0 to 6.0.7 nbb's require.resolve path failed after upgrading A local main-export mapping change restored resolution for the reporter
#467, historical TypeScript setup Users encountered syntax, extension and unresolved $ errors Commenters reported tsup and .mts scripts through tsx as workarounds

The maintainer's advice in #164 was to construct the complete argument in JavaScript. That recommendation addresses a script adding its own quotes around interpolated values, which zx already escapes. Issue #471 describes a separate symptom involving a colon and an added dollar sign. Its reporter identified a change between 7.0.3 and 7.0.4, while the discussion also contains disagreement about reproduction. The reported version and input belong together when diagnosing that error.

The setup guide documents useBash(), usePowerShell() and usePwsh(). Issue #523 explains why shell selection matters on Windows: PowerShell rejected a Bash-style option, and louisgv described bash entering WSL with a different filesystem. Packaging presents another boundary. The guide's hybrid CJS and ESM entry points are the current documented starting point alongside the older zx 3.0.0 CommonJS request in #197.

Command logging and argument escaping need separate choices

Issue #91's maintainer response says non-verbose mode displays nothing and the script decides what to print. Argument escaping and terminal output therefore address different parts of a command's behavior. The README describes escaping interpolated arguments; the #91 discussion recommends explicitly printing the needed result. A script handling a credential needs an output policy as well as a decision about how that credential reaches the external command.

In issue #306, users asked to hide commands containing sensitive information while retaining output. The thread also discusses capturing stdout while displaying stderr and an interactive command whose prompt disappeared while the process waited for input. Discarding stdout and retaining it for later processing are different outcomes. The issue's examples and requests are useful for defining a script's requirements: command display, captured results, error output and prompts each serve a separate purpose.

zx vs Bash, child_process, PowerShell and npm tasks

Lakatos preferred Bash for simple arithmetic and JavaScript for JSON, while Wargo chose zx to simplify process spawning in a language he already knew. These are attributed choices about specific scripts. They make maintainability a useful comparison rather than establishing a universal winner. An npm task can also remain the entry point to a separate zx file, preserving the command contributors use while moving larger automation out of a package.json string.

Alternative Why someone might choose it Where zx earns its place
Bash in Lakatos's comparison He found it clearer for adding two command-line numbers He already knew how to parse JSON in JavaScript
Node.js child_process in Wargo's account It exposes direct process-spawning capabilities Wargo preferred zx's simpler sequencing and output handling
PowerShell in Wargo's account It was another scripting option he considered He wanted to avoid learning another language
npm tasks in the Hacker News discussion A short command can stay in package.json A larger zx script can still be started through npm run
tsx in #467 It can launch a TypeScript script A commenter used it together with zx/globals

In issue #247, r0binary described an SSH wrapper configured as zx's shell, using noninteractive public-key authentication. The working-directory setting affected the locally spawned process, so the remote-directory workaround added a cd command to the prefix. The issue author's Ansible comparison was an aspiration about replacing it in some scenarios. The concrete implementation described in the discussion is the wrapper experiment and its handling of the remote working directory.

What the other reviews get wrong

Global installation is optional, and Wargo's statement about running on any OS describes his own consolidated workflow. These corrections concern Alex Lakatos's “Meet zx: A Better Way to Write Scripts with Node.js” and John M. Wargo's “zx for Simplified Node Process Spawning.” Their examples remain useful when read at that scope: Lakatos demonstrates why he preferred JavaScript for JSON, while Wargo explains scripts built around his existing tools and language knowledge.

Lakatos's 2021 introduction says zx needs global installation before scripts can run. The setup documentation's npx example runs a script without installing zx as a project dependency, making that prerequisite too broad. Wargo's Android workflow uses adb, and his article also acknowledges external-command portability. The PowerShell rejection of -rf in #523 shows why readers should identify the shell and executables behind a shared script rather than generalize from one author's successful workflow.

FAQ

Lakatos's comparison favors zx for familiar JavaScript JSON handling and Bash for adding two command-line numbers. For a first script, the getting-started guide specifies .mjs for top-level await and shows the zx ./script.mjs launcher. Those facts answer the initial choice and launch questions. The versioned reports below address narrower problems with quoting, output, shell selection and module loading, each tied to the author or issue that described it.

When is zx a better choice than Bash for scripting?

Lakatos preferred JavaScript for parsing JSON and Bash for adding two command-line numbers. His comparison describes both choices, giving a practical way to assess a growing script. Look at which part occupies the code: shell commands, or the conditions and structured data around them. Familiarity with JavaScript was a concrete advantage in his JSON example, rather than a reason to replace his simpler arithmetic script.

Why use zx instead of Node's child_process module?

Wargo chose zx to simplify process spawning and the surrounding sequencing and output handling. His article compares that work with direct Node process calls. The getting-started guide describes zx's command template as returning a ProcessPromise. Together, those descriptions identify the decision: whether the command interface removes process-management code that the script's maintainers would otherwise write themselves.

Why choose zx instead of PowerShell?

Wargo's decisive reason was his existing JavaScript knowledge and desire to avoid learning another language. He said installing PowerShell instead of zx was no big deal, so installation was secondary in his account. That is a reason grounded in his own skills. A team's comparison can begin with the language its maintainers already use and the external commands its script needs.

Should larger JavaScript automation scripts use zx or npm tasks?

A separate zx script can still be launched through an npm task. The Hacker News discussion distinguishes inline package.json commands from scripts started through npm run. That arrangement preserves a familiar project entry point while putting a larger program in its own file. The comparison concerns where automation code lives, rather than requiring contributors to abandon their existing npm command.

Why do interpolated zx arguments gain dollar signs or unexpected quotes?

Issue #164 describes quoting trouble in zx 2, while #471 reports an extra dollar sign in 7.0.4 and 7.0.5. The maintainer's #164 advice was to move the complete argument into a JavaScript variable. The #471 report concerns a value containing a colon. These are different symptoms, so the input, shell and package version are useful details to retain in a diagnosis.

How can I hide executed commands while still displaying their output?

Issue #91 recommends non-verbose execution followed by explicitly printing the needed result. The maintainer says the script decides what to display. This makes output selection part of the script itself. Issue #306 separately describes users who wanted finer control, including a command containing sensitive information and an interactive prompt hidden while the process waited for input.

How can I capture stdout without displaying it while keeping stderr visible?

Issue #306 asks for captured stdout and visible stderr as separate output requirements. A commenter distinguishes retaining output from discarding it, which matters when later JavaScript needs the command result. The same discussion includes interactive prompts, adding another requirement beyond stream capture. Its examples describe the combinations users wanted, rather than making all hidden-output behavior equivalent to sending stdout to a null destination.

How do I force zx to use Bash on Windows?

The setup guide documents useBash() as the helper for switching back to Bash. Its shell-helper example also shows usePowerShell() and usePwsh(), naming the alternatives explicitly. Issue #523 explains the motivation: a script using rm -rf reached PowerShell and received a parameter error. The helper selects Bash, while the next question concerns which Bash environment the executable represents.

How can zx distinguish WSL Bash from Git Bash on Windows?

Issue #523 records a user reporting that bash entered WSL and changed the filesystem paths seen by the script. The discussion asks how to distinguish WSL from Git Bash. That report identifies a second shell-selection problem after the PowerShell error: selecting the name Bash and selecting the intended Windows Bash environment are separate configuration questions.

Why does require.resolve fail to locate zx after an upgrade?

borkdude reported nbb resolution failing after an upgrade from zx 5.3.0 to 6.0.7. The error in #382 is ERR_PACKAGE_PATH_NOT_EXPORTED, and the reporter described restoring resolution with a local main-export mapping change. The consuming tool and both versions identify the integration involved. That is more specific than treating the report as a general failure to import zx from every Node program.

Can zx provide a synchronous CommonJS entry point for ts-node scripts?

The setup guide documents both CommonJS and ECMAScript module entry points. The older #197 request concerns zx 3.0.0 and synchronous CommonJS loading for ts-node. Its requested behavior explains why the entry-point distinction matters. The hybrid-package example shows both require and import forms, so that documentation is the starting point for choosing the package format a script consumes.

How do I run TypeScript scripts with zx and make the $ global resolve correctly?

A commenter in #467 reported using an .mts file, tsx and an import of zx/globals. That historical workaround names the runner and extension together. The setup guide separately says zx includes TypeScript definitions and requires user-installed @types/node and @types/fs-extra. Execution configuration and editor types therefore have distinct documented parts, even when they appear together in the same TypeScript script.

What we have not tested yet

The source-test tail omits underlying exceptions, and the quickstart ended at JavaScript parsing. These results support neither a root-cause diagnosis nor a complete passing-test count. No successful rerun through the documented launch routes is recorded. The source checkout's 266 MB environment and the npm quickstart's 976 KB installation describe different procedures. The lab-node:22 label supplies neither an actual runtime reading nor an operating-system version.

The older quoting, Windows, nbb and TypeScript reports have not been reproduced in these runs, and their extracts leave specific released fixes unresolved. Issue #306 provides no complete implemented recipe covering command logging, captured stdout, visible stderr and interactive prompts together. The Windows discussion supplies no confirmed method for distinguishing WSL Bash from Git Bash. The SSH wrapper and proposed Ansible replacement have no lab result here, and #247 supplies no release history for remote execution.

No controlled startup, throughput, memory or concurrency comparison with Bash, Python, Ruby or PowerShell was performed. The zero-advisory npm audit result concerns known dependency advisories, rather than credential handling or arbitrary-script security. Production reliability and named-company adoption are outside these observations. Rendered layout, related links and recommendation modules were also outside this text review. The next evaluation can use one existing JSON-heavy script, recording its shell, external executables, output and failure behavior on each intended machine.

Alternatives

ProjectWhat it isPick it when
BashLakatos preferred Bash for adding two command-line numbers.Keep Bash when the existing script is clearer; Lakatos preferred JavaScript when his task shifted to JSON parsing.
Node.js child_process gh↗The process-spawning API zx wraps.Use it directly when you want to manage sequencing and process output yourself; Wargo chose zx to reduce that work.
PowerShell gh↗A scripting alternative Wargo considered.Consider it when your team already knows PowerShell; Wargo's deciding factor was his existing JavaScript knowledge.
npm tasks gh↗Package scripts can launch a command or a separate zx file.Keep short commands inline, or keep npm run as the entry point while moving larger automation into a zx script.

Sources

  1. google/zx README
  2. zx getting started
  3. zx setup and hybrid packaging
  4. zx CLI launch routes
  5. Alex Lakatos: Meet zx
  6. John M. Wargo: zx for Simplified Node Process Spawning
  7. Hacker News: zx scripting discussion

More dev tools reviews