Skip to content

Windows: npm global install creates broken shims that reference /bin/sh #262

@orro3790

Description

@orro3790

Description

When installing agent-browser globally on Windows via npm install -g agent-browser, the generated shims (.ps1 and .cmd) fail because they reference /bin/sh which doesn't exist on Windows.

Steps to Reproduce

  1. On Windows, run: npm install -g agent-browser
  2. Run: agent-browser open https://example.com

Expected Behavior

The command should work, using the native Windows binary (agent-browser-win32-x64.exe).

Actual Behavior

PowerShell error:

& "/bin/sh.exe" ...
The term '/bin/sh.exe' is not recognized as a name of a cmdlet, function, script file, or executable program.

CMD error:

The system cannot find the path specified.

Root Cause

The generated shims in %APPDATA%\npm\ point to the shell script wrapper instead of the native Windows binary:

agent-browser.ps1 tries to run:

& "/bin/sh$exe" "$basedir/node_modules/agent-browser/bin/agent-browser" $args

agent-browser.cmd tries to run:

SET "_prog=/bin/sh"

Workaround

Manually overwrite the shims to use the native binary:

agent-browser.cmd:

@ECHO off
"%~dp0\node_modules\agent-browser\bin\agent-browser-win32-x64.exe" %*

agent-browser.ps1:

#!/usr/bin/env pwsh
$basedir = Split-Path $MyInvocation.MyCommand.Definition -Parent
& "$basedir\node_modules\agent-browser\bin\agent-browser-win32-x64.exe" $args
exit $LASTEXITCODE

Suggested Fix

Update package.json bin field to properly handle Windows, either by:

  1. Using a cross-platform bin wrapper that detects the OS and runs the appropriate binary
  2. Using npm's platform-specific bin configuration

Environment

  • OS: Windows 11
  • Node.js: v22.20.0
  • npm: (global install)
  • agent-browser: 0.6.0

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