Skip to content

Install fails and playwright never gets installed correctly #1091

@Ismael

Description

@Ismael

I installed a previous version of agent-browser, and at some point it stopped working. I tried using npm install -g agent-browser
Which got me 0.23.1

Platform: Debian Linux x86_64 (glibc), Node.js v22.21.1, npm 9.2.0

Then I ran agent-browser install, which succeded.

Running any command (like agent-browser open example.com) got me:

  ✗ browser.newContext: Cannot find module './../../../package.json'
  Require stack:                                                                                                                                                                                                                           
  - /.../.npm-global/lib/node_modules/agent-browser/node_modules/playwright-core/lib/server/utils/userAgent.js                                                                                                                           
  - /.../.npm-global/lib/node_modules/agent-browser/node_modules/playwright-core/lib/server/registry/browserFetcher.js   

I tried install playwright globally, no change.

I let Claude find and fix the issue, and this is what it found:


The native binary embeds Node.js and resolves playwright-core relative to its own install directory (/node_modules/playwright-core/). However, playwright-core is not declared in package.json's dependencies field (which is empty {}), so npm install never fetches it, and the expected path does not exist.

Workaround

Manually install playwright-core inside the package directory after installation:

cd $(npm root -g)/agent-browser
npm install playwright-core

After this, agent-browser open example.com works correctly.

Expected behavior

playwright-core should be listed as a dependency in package.json so it is installed automatically by npm.

Suggested fix

Add playwright-core (version 1.58.2 or whichever version the binary targets) to the dependencies field in package.json:

"dependencies": {
"playwright-core": "1.58.2"
}


Sorry if this issue was somehow caused by me doing the install/update wrong, feel free to close if not relevant.

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