-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bun add puppeteer
doesn't run postinstall script for trusted dependency
#4705
Comments
I found a little workaround for now: in my package.json I added a postinstall script with using the puppeteer CLI to install the missing chrome driver. |
@dr-noid I feel you are right, Chrome was not downloaded when I installed puppeteer with bun. |
same here. postinstall ^ worked though 🙏 |
I am on m1 pro mac and adding the postinstall script did run the post-install command after running
UPDATE: I fixed it by using the specific chrome version to install in the postinstall script. |
@Alino glad you found a fix, this issue probably won't get any traction because from the outside it looks like an issue with puppeteer. I haven't done any testing on this but my guess is this is an issue with trustedDependencies and postinstall scripts as a whole. |
It's a two fold problem.
See #4894 |
Related #4959 |
|
@azat-io i don't have much experience with docker so I don't know how the filesystem structure is laid out, you could always omit the |
So I haven't been able to reproduce the issue using your procedure (the first install of puppeteer on a system using bun in a brand new project has consistently worked for me so far) but I've experienced a lot of similar issues on subsequent runs of I think the problem basically stems from bun only calling postinstall scripts when you first add a package (aka when it first gets added to If the files created by puppeteer's postinstall script (in ~/.cache/puppeteer) are damaged or removed, they'll stay that way because
|
@An-GG thanks for your response, I actually tried to look more into it after you mentioned the You can recreate the problem like this:
However, it does run the postinstall script if I do this: |
@dr-noid That's really interesting - so even just an empty I had assumed this was a result of too eagerly reusing cached installs of packages, but it seems like its a much more glaring bug. Personally I am still confused on the proper usage of I have no evidence of this but specifically regarding the puppeteer postinstall issue, I think at one point I encountered better success with using |
@An-GG I have only been able to get Bun to run the postinstall hook when I did |
How do you guys manage to run it at all? All I'm getting at any case, when trying to install a browsers, is: sc@SC-FVF:~/www/buntest$ bunx @puppeteer/browsers install [email protected] --path $HOME/.cache/puppeteer
[0.01ms] ".env"
92 | if (required) {
93 | yargs.demandOption('path');
94 | }
95 | }
96 | async run(argv) {
97 | const yargsInstance = (0, yargs_1.default)((0, helpers_1.hideBin)(argv));
^
TypeError: (0, yargs_1.default) is not a function. (In '(0, yargs_1.default)((0, helpers_1.hideBin)(argv))', '(0, yargs_1.default)' is "/home/sc/www/buntest/node_modules/@puppeteer/browsers/node_modules/yargs/yargs")
at /home/sc/www/buntest/node_modules/@puppeteer/browsers/lib/cjs/CLI.js:97:14
at run (/home/sc/www/buntest/node_modules/@puppeteer/browsers/lib/cjs/CLI.js:96:14)
at /home/sc/www/buntest/node_modules/@puppeteer/browsers/lib/cjs/main-cli.js:20:5
at globalThis (/home/sc/www/buntest/node_modules/@puppeteer/browsers/lib/cjs/main-cli.js:20:40)
error: "browsers" exited with code 1 (SIGHUP) Puppeteer installed is |
@dr-noid Adding typescript, then puppeteer doesn't work
But adding puppeteer, then typescript works
crazy what a weird bug |
Not working for me under Ubuntu 22.04.2 LTS, getting this output:
|
alternative solution: |
I've been holding off switching from Node to Bun due to this exact issue with Puppeteer, and it's the first thing I see when looking at issues with Bun/Puppeteer. Definitely not a Bun issue but an issue with Puppeteer. @dr-noid Since you launched Puppeteer with headless set to false, Puppeteer was not defaulting to using your existing Chrome browser? This would be the expected behaviour or you were running on your local machine. Very similar to some of the issues I ran into when setting up Puppeteer with Docker. I'll take a look at this, looks like the perfect issue to help resolve and also switch to Bun! |
@nigelnindodev I do all of my programming in WSL so no it doesn't. |
In my case (using
|
Duplicate of #4959 (we fill fix this) |
even after trying the fixes here, I couldn't get it to work. #5416 worked for me. (running on WSL Ubuntu) |
This was fixed, we run |
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"]
topackage.json
package.json reference:
bun add puppeteer
bun install
index.ts
: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
npm install
) orFor (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.The text was updated successfully, but these errors were encountered: