heroku Error: compiled slug size: is too large with Puppeteer
Asked Answered
S

1

5

My app is working on localhost but when i deploy on heroku this module is required for puppeteer app https://github.com/jontewks/puppeteer-heroku-buildpack. puppeteer node_module size is around 300mb and this module size is 200.Total size is 539mb. Please suggest a good solution

Seventy answered 28/2, 2022 at 18:2 Comment(3)
Hi, did you find the solution to this problem? I'm also facing it; couldn't resolve yet.Hyperopia
@Hyperopia nope. I deployed the app on Google app engineSeventy
cool thank you, anyway I found the solution to use the Playwright instead. It reduces the bundle size greatly. Here is the guide (if anyone is looking for solution): https://mcmap.net/q/2032526/-how-to-reduce-puppeteer-sizeHyperopia
C
8

Faced the same issue.

The following steps reduced my slug size from around 530MB to around 250MB.


1 — Update buildpacks

Add the heroku/google-chrome buildpack. Place it above the heroku/nodejs buildpack. The jontewks/puppeteer-heroku-buildpack is not required here anymore.

buildpacks


2 — Add new ENV variables

Add PUPPETEER_EXECUTABLE_PATH. In your local environment, set this env variable as \path\to\chrome.exe. In Heroku, set this env variable as google-chrome.

Also add PUPPETEER_SKIP_DOWNLOAD, and set it to true. This tells Puppeteer to skip downloading Chromium.

env variables


3 — Update Puppeteer config

Puppeteer's launch options includes executablePath. Set this to PUPPETEER_EXECUTABLE_PATH.

puppeteer config


4 — Deploy, you're done!

Push commit to Heroku to trigger new deployment. Hopefully, your slug size will have reduced by then, and your Heroku app should be able to deploy successfully.

slug size

Contraption answered 20/12, 2022 at 3:34 Comment(3)
This was very helpful for me! My project's slug size went from ~490mb down to ~290mb. Thank you!Bicorn
Seriously! Went from 499.2 to 286. I was also stuck on Puppeteer 18. Thank you so much!Tartary
I did exactly what you mentionned but got this when launching puppeteer : Error: Browser was not found at the configured executablePath (google-chrome). Any idea ?Laband

© 2022 - 2024 — McMap. All rights reserved.