Skip to content

fix(installer): Windows npm launcher EINVAL on modern Node (#289)#292

Merged
colbymchenry merged 1 commit into
mainfrom
fix/win-npm-shim-einval-289
May 22, 2026
Merged

fix(installer): Windows npm launcher EINVAL on modern Node (#289)#292
colbymchenry merged 1 commit into
mainfrom
fix/win-npm-shim-einval-289

Conversation

@colbymchenry
Copy link
Copy Markdown
Owner

Problem

On Windows, npm i -g @colbymchenry/codegraph followed by any codegraph command fails with:

codegraph: spawnSync …\codegraph-win32-x64\bin\codegraph.cmd EINVAL

The npm thin-installer shim (scripts/npm-shim.js) located the per-platform bundle and spawnSync'd its .cmd launcher directly. Modern Node on Windows refuses to spawn .cmd/.bat files without shell: true (the CVE-2024-27980 hardening) — it throws EINVAL. The reporter is on Node v24.11.0. Closes #289.

Fix

On Windows the shim now resolves the bundle's node.exe and the app entry (lib/dist/bin/codegraph.js) and spawns those directly, bypassing the .cmd. This mirrors exactly what the .cmd does and avoids shell: true (which doesn't auto-quote array args on Windows and widens the injection surface). The unix path (a shell-script launcher) is unchanged.

Validation

Verified end-to-end on Windows (host Node v22.22.0) against a real win32-x64 bundle built via build-bundle.sh (official Node v24.16.0 runtime + compiled app + prod deps), packed with npm pack, and npm installed from the tarballs into a clean dir:

Command Before After
codegraph init -i (repro) spawnSync …codegraph.cmd EINVAL indexed 288 files, 4,575 nodes, exit 0
codegraph status Backend: node:sqlite - built-in (full WAL)

The status line confirms the bundled Node 24 ran (node:sqlite doesn't exist on the host's Node 22), proving the shim launched node.exe, not the .cmd.

Release

Cuts 0.9.2, rolling up everything pending since v0.9.1: Drupal 8/9/10/11 support, zero-config indexing, the breaking config-surface removal, the Hermes Agent installer target, and the symlink-marker security fix. Changelog and package.json/package-lock.json bumped. (npm publish is still gated behind the manual Release workflow — not triggered here.)

🤖 Generated with Claude Code

The npm thin-installer shim spawned the per-platform bundle's `.cmd`
launcher directly. Modern Node on Windows refuses to spawn `.cmd`/`.bat`
without `shell: true` (the CVE-2024-27980 hardening), so every `codegraph`
command failed with `spawnSync …\codegraph.cmd EINVAL` (seen on Node 24).

On Windows the shim now invokes the bundled `node.exe` against the app
entry point directly, bypassing the `.cmd` (and avoiding the arg-quoting
pitfalls of `shell: true`). Unix is unchanged.

Validated end-to-end against a real win32-x64 bundle: `npm install` of the
packed tarballs + `codegraph init -i`/`status` run on the bundled Node 24.

Also cuts release 0.9.2, rolling up the pending Drupal, zero-config,
config-removal, Hermes-installer, and symlink-security changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EINVAL

1 participant