Skip to content

fix: add prebuilt binaries for node-pty to fix npx installation #29

Closed

Description

@dwmkerr

Problem

Running shellwright via npx -y @dwmkerr/shellwright fails with:

Error: posix_spawnp failed.

This happens because node-pty is a native module that requires compilation. When npx installs to its cache directory, the compilation can fail silently, leaving broken binaries.

Current Workaround

Install globally instead of using npx:

npm install -g @dwmkerr/shellwright
claude mcp add --scope user shellwright -- shellwright

Proposed Solution

Add prebuilt binaries so native compilation isn't required at install time.

Options

  1. prebuild + prebuild-install

    • Build binaries in CI for each platform/Node version
    • Users download prebuilt binary at install time
    • Fallback to compilation if no matching binary
  2. node-pre-gyp

    • Similar approach, hosts binaries on S3/GitHub releases
    • More established but more complex setup
  3. Optional dependencies

    • Use @aspect-build/node-pty-prebuilt-multiarch or similar
    • Less control but zero setup

CI Changes Needed

Build matrix for:

  • Platforms: linux-x64, linux-arm64, darwin-x64, darwin-arm64, win32-x64
  • Node versions: 18, 20, 22

References

Activity

  1. dwmkerr commented on Jan 4, 2026

    @dwmkerr
    OwnerAuthor

    Root Cause Identified

    The issue is not missing prebuilt binaries - it's a bug in node-pty 1.1.0.

    The Bug

    node-pty 1.1.0 ships prebuilt binaries with incorrect file permissions:

    • spawn-helper is packaged as 644 (not executable)
    • Should be 755 (executable)

    When npm/npx extracts the tarball, spawn-helper can't execute, causing posix_spawnp failed.

    Why Local Dev Works

    shellwright's package.json uses ^1.0.0, and the local lockfile resolved to 1.0.0. This version compiles from source via node-gyp, which sets correct permissions.

    When installed via npx (no lockfile), npm resolves ^1.0.0 to latest compatible = 1.1.0, hitting the bug.

    Upstream Issue

    microsoft/node-pty#850

    Fix

    Pin to node-pty: "1.0.0" (exact version) until node-pty releases a fix (likely 1.2.0).

    This means users need build tools (Xcode CLI / build-essential), but it works reliably.


    Keeping this issue open to track upgrading to node-pty 1.2.x when released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions