How to use puppeteer? #124
Replies: 20 comments 78 replies
-
I ended up using Playwright. |
Beta Was this translation helpful? Give feedback.
-
Hi, this worked for me: first:
then: // import * as puppeteer from 'puppeteer';
import chromium from 'chrome-aws-lambda';
// const browser = await puppeteer.launch( { args: ['--no-sandbox'] } );
const browser = await chromium.puppeteer.launch({
args: [...chromium.args, "--hide-scrollbars", "--disable-web-security"],
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath,
headless: true,
ignoreHTTPSErrors: true,
}) |
Beta Was this translation helpful? Give feedback.
-
@diegoguevara's answer was really helpful (thank you!), but the missing piece for me was that this won't work locally (at least with my basic express app set up), so I thought it didn't work at all, even though it did in fact work when published to Vercel. My approach to get the best of both worlds (which I partially borrowed from a Japanese article 😄) was to detect whether or not
Note that, because of this, I installed |
Beta Was this translation helpful? Give feedback.
-
This should work:
The only thing you need to do, is to manually set either one of these environment variables to some value:
For some reason, they are not set in Vercel. h/t @leerob |
Beta Was this translation helpful? Give feedback.
-
I also had an issue with this. This works locally for me absolutely fine using
This dependency is in my |
Beta Was this translation helpful? Give feedback.
-
If anyone comes across this thread, just wanted to point to this closed issue: vercel/vercel#4739 Basically theres still, at the time of writing, a vercel deployment issue - something about sharing code between the api routes and other files which cause the size to balloon. If you move your |
Beta Was this translation helpful? Give feedback.
-
Im getting this error after trying every single solution in this thread, any help please.
|
Beta Was this translation helpful? Give feedback.
-
I tried everything mentioned here but still cant get it working. My dependencies:
How i try to start the browser:
Locally everything works fine. But on vercel i get:
Does anyone know whats going wrong here? |
Beta Was this translation helpful? Give feedback.
-
It works if you only use puppeteer + chrome-aws-lambda in that server. |
Beta Was this translation helpful? Give feedback.
-
um.... not work for me by using puppeteer or Playwright. |
Beta Was this translation helpful? Give feedback.
-
I think that puppeteer doesn't work in node v16 |
Beta Was this translation helpful? Give feedback.
-
Also oddly enough, I see this output about my However it still seems to work in that deployment 🤔 This is with the latest |
Beta Was this translation helpful? Give feedback.
-
I'm getting this issue - Vercel is unable to find the path to the browser. Does anyone know how to fix this??
|
Beta Was this translation helpful? Give feedback.
-
This is an official solution from Vercel and it works fine for me: https://github.com/vercel/virtual-event-starter-kit/blob/main/lib/screenshot.ts Only the latest versions of |
Beta Was this translation helpful? Give feedback.
-
Hey! If anyone is still trying to use Chromium/Puppeteer for taking screenshots inside Serverless Functions, could you send me an email |
Beta Was this translation helpful? Give feedback.
-
I am trying to use puppeteer but my deployment fails. I am using remix. |
Beta Was this translation helpful? Give feedback.
-
Getting this error for playwright on vercel 👀 |
Beta Was this translation helpful? Give feedback.
-
Any updates or possible solutions? |
Beta Was this translation helpful? Give feedback.
-
Hello Guys, I am getting an error on vercel:
and this is my code:
can anyone help with that? |
Beta Was this translation helpful? Give feedback.
-
Hi, folks. If you're still struggling to make this work, I wrote a guide about how I achieved Chromium on Vercel serverless today.
It lists the exact steps you need to take, emphasizes the right dependency versions to use (yes, those do matter), and includes solutions to the common problems I (and many of you here) faced while trying to make this work, like Build something awesome. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to get puppeteer working on vercel, does anyone have experience getting it working?
I get the following error at the point browser is launched:
puppeteer failed: Error: Could not find browser revision 768783. Run "PUPPETEER_PRODUCT=firefox npm install" or "PUPPETEER_PRODUCT=firefox yarn install" to download a supported Firefox browser binary.
It should be running chromium, but the error suggests using firefox, which I could not find a way how to do.
Beta Was this translation helpful? Give feedback.
All reactions