@shukelabs/jq
v1.0.0
Published
The jq command for machines that can only install npm packages: official jq compiled to WebAssembly (via jq-wasm), no native binary.
Readme
@shukelabs/jq
The jq command for machines where the only thing you can install is an npm package.
npm install -g @shukelabs/jq
jq --version # jq-1.8.2What this is, and what it is not
This is not a replacement for jq, and not a fork or a
reimplementation of it. If you can install jq the normal way (apt, brew, winget, scoop,
or the official release binaries), do that. Native jq
is faster and has none of the limitations below.
It exists for one situation: a locked-down machine where native executables cannot be
downloaded or installed, but Node.js and an npm registry are available. There, tools and
scripts that call jq can still work.
The actual jq is the official jq source compiled to WebAssembly by
jq-wasm. This package adds a small command-line
wrapper (bin/jq.mjs) that turns jq [options] filter [files...] into a jq-wasm call. It ships
no native binary and runs no install scripts.
Differences from native jq
jq runs inside a WebAssembly sandbox. The wrapper bridges what it can and refuses what it cannot, rather than produce a silently different result:
| Feature | Behaviour |
| --- | --- |
| Input files, -f, --slurpfile, --rawfile | Supported. The wrapper reads the files and hands their contents to jq. |
| --args, --jsonargs, -L / modules | Rejected with exit code 2. |
| Streaming input | Not supported: nothing is printed until stdin reaches end of file, so tail -f log \| jq does not work. |
| -n | Input is read only when the filter mentions input or inputs; a stray "input" inside a string literal also counts. |
| $ENV, env | See the sandbox environment, not your shell's. |
| localtime, strflocaltime | Use UTC. |
| input_filename | Always null. |
| -C (color) | Ignored; output is never colored. |
| Line endings | Always LF, also on Windows (native Windows jq writes CRLF). |
| Startup | About 0.3 s per call (Node.js start-up), against about 0.1 s for native jq. |
Apart from these, the test suite checks that output and exit codes match native jq. CI runs that comparison against the runner's own jq on every push.
Requirements
Node.js 20 or later.
Licence
MIT. jq and jq-wasm are also MIT-licensed; see their repositories.
