4

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

James Z
  • 12,209
  • 10
  • 24
  • 44
Adnan Hassan
  • 105
  • 7
  • Hi, did you find the solution to this problem? I'm also facing it; couldn't resolve yet. – Haseeb Sep 16 '22 at 10:45
  • @Haseeb nope. I deployed the app on Google app engine – Adnan Hassan Sep 17 '22 at 11:25
  • 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://stackoverflow.com/a/69481396/12824406 – Haseeb Sep 18 '22 at 12:13

1 Answers1

4

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

lefrost
  • 461
  • 5
  • 17