Skip to content

bun add puppeteer doesn't run postinstall script for trusted dependency #4705

@dr-noid

Description

@dr-noid

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

mkdir bun-puppeteer
cd bun-puppeteer
bun init
add "trustedDependencies": ["puppeteer"] to package.json
package.json reference:

{
  "name": "bun-puppeteer",
  "module": "index.ts",
  "type": "module",
  "devDependencies": {
    "bun-types": "latest"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "trustedDependencies": [
    "puppeteer"
  ]
}

bun add puppeteer
bun install

index.ts:

import puppeteer from "puppeteer";
await puppeteer.launch({ headless: false });

bun run index.ts

What is the expected behavior?

bun run starts a headless browser

What do you see instead?

bun-puppeteer $ bun run index.ts

269 | if (this.puppeteer.configuration.browserRevision) {
270 | throw new Error(Tried to find the browser at the configured path (${executablePath}) for revision ${this.puppeteer.browserRevision}, but no executable was found.);
271 | }
272 | switch (this.product) {
273 | case 'chrome':
274 | throw new Error(Could not find Chrome (ver. ${this.puppeteer.browserRevision}). This can occur if either\n +
^
error: Could not find Chrome (ver. 116.0.5845.96). This can occur if either

  1. you did not perform an installation before running the script (e.g. npm install) or
  2. your cache path is incorrectly configured (which is: /home/drnoid/.cache/puppeteer).
    For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
    at resolveExecutablePath (/home/drnoid/coding/bun-puppeteer/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:274:26)
    at /home/drnoid/coding/bun-puppeteer/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:92:31
    at processTicksAndRejections (:1:2602)

Additional information

There is a 99.9% chance that this is an issue with the postinstall script of puppeteer.
If I install puppeteer with pnpm or npm it will run the postinstall script and download the browser in the .cache directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions