Bhaumin
Bhaumin•3mo ago

Please help to run puppeteer with deno?

GitHub
GitHub - Beingminimal-gh/deno-puppeteer
Contribute to Beingminimal-gh/deno-puppeteer development by creating an account on GitHub.
19 Replies
Deno AI Helper
Deno AI Helper•3mo ago
I'm sorry, but I wasn't able to find the answer to your question in the official Deno documentation. However, I can take a look at the code you've provided to see if there are any obvious syntax errors or mistakes. After reviewing the code you linked to, here are a few general points to consider: 1. Ensure that you are using a Deno-compatible library for Puppeteer. The standard Puppeteer library is designed for Node.js, and Deno has different APIs and module resolution semantics. 2. Check that you have the necessary permissions enabled when running your Deno script, as Puppeteer will require permissions to access the network, file system, etc. 3. Verify that any dependencies are properly imported using URLs, as Deno does not use the node_modules system that Node.js does. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. If you continue to have issues, you might want to look for Deno-specific resources or community examples of Puppeteer with Deno, as the Deno ecosystem is distinct from Node.js and may have different best practices or available libraries.
Chad Taylor
Chad Taylor•3mo ago
I couldn't pull the devcontainer image (unauthorized), but I did test using Ubuntu 24.04. I can replicate the issue. The problem is that the downloaded version of Chrome requires at least one uninstalled shared library (libgobject-2.0 on my fresh Ubuntu install). I was able to get your program test-1.ts working with the following two steps: 1. Install Chrome directly instead of pulling it via the deno script
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install -y ./google-chrome-stable_current_amd64.deb
rm ./google-chrome-stable_current_amd64.deb*
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install -y ./google-chrome-stable_current_amd64.deb
rm ./google-chrome-stable_current_amd64.deb*
2. Update the puppeteer.launch command to include executable path. (I also like to include the headless parameter, but that is optional.)
const browser = await puppeteer.launch({ headless: true, executablePath: "/usr/bin/google-chrome" });
const browser = await puppeteer.launch({ headless: true, executablePath: "/usr/bin/google-chrome" });
Then you can just run with deno run -A ./test-1.ts (no unstable flag necessary).
Bhaumin
Bhaumin•3mo ago
ok thanks a lot for support, i will try and let you know.
Doctor 🤖
Doctor 🤖•3mo ago
A possible alternative: https://jsr.io/@astral/astral
JSR
@astral/astral - JSR
@astral/astral on JSR: Astral is the browser automation library for Deno
marvinh.
marvinh.•3mo ago
^Another vote for astral. It's the easiest way to get chromium running in Deno
Bhaumin
Bhaumin•3mo ago
Experimental WebDriver BiDi support | Puppeteer
WebDriver BiDi is a new cross-browser
marvinh.
marvinh.•3mo ago
No, astral uses the CDP protocol under the hood
Chad Taylor
Chad Taylor•3mo ago
I am unfamiliar with Astral, so I decided to try it out to see if it would work around the issues described in the original post. I used the screenshot example from the Astral page you linked on a fresh Ubuntu install. I get the same root error:
/home/vscode/.cache/astral/125.0.6400.0/chrome-linux64/chrome: error while loading shared libraries: libgobject-2.0.so.0: cannot open shared object file: No such file or directory

Process exited with code 127
error: Uncaught (in promise) Error: Your binary refused to boot
throw new Error("Your binary refused to boot");
/home/vscode/.cache/astral/125.0.6400.0/chrome-linux64/chrome: error while loading shared libraries: libgobject-2.0.so.0: cannot open shared object file: No such file or directory

Process exited with code 127
error: Uncaught (in promise) Error: Your binary refused to boot
throw new Error("Your binary refused to boot");
I still recommend installing Chrome by the steps provided above. If you do that, you'll want to set the path when launching a browser via Astral otherwise it will download Chrome again.
jeff.hykin
jeff.hykin•3mo ago
@lino-levan ^ (I'm gonna guess the answer is "no")
ioB
ioB•3mo ago
webdriver bidi is really not ready yet happy to release an experimental build with support if you need it it looks like you're missing some system dependencies, were you trying to do this within docker or something? I will create an issue to have a better error message (one with commands to run)
Bhaumin
Bhaumin•2mo ago
Chrome for Developers
WebDriver BiDi production-ready in Firefox, Chrome and Puppeteer  |...
Puppeteer 23 introduces stable support for Firefox 129 and up, offering a unified API for Chrome and Firefox automation, based on WebDriver BiDi.
Bhaumin
Bhaumin•2mo ago
Can you please share issue link?
ioB
ioB•2mo ago
GitHub
Better error message for missing chromium system dependencies · Iss...
In some situations (like in docker containers), we fail to boot the binary because of missing system dependencies. Here is an example log: /home/vscode/.cache/astral/125.0.6400.0/chrome-linux64/chr...
ioB
ioB•2mo ago
already landed in main, I don't believe I've cut a release yet
ioB
ioB•2mo ago
https://github.com/lino-levan/astral/issues/84 created this issue for webdriver bidi if you want to follow it
GitHub
Support WebDriver BiDi · Issue #84 · lino-levan/astral
Firefox's CDP implementation is so incomplete that I believe the best course of action is to create a second backend for Astral. WebDriver BiDi is theoretically cross-browser compatible so in t...
Bhaumin
Bhaumin•2mo ago
So we should ditch Puppeteer by using astral?
ioB
ioB•2mo ago
If you're looking for a deno-native browser automation solution, that's what I would recommend (I also happen to be the author of the library so I have a bit of bias here).
Bhaumin
Bhaumin•2mo ago
Haha ok cool.