Running puppeteer during build

Hi, I’m trying to use puppeteer during a build/deploy, and am getting the following error:

Failed to launch the browser process!
/opt/build/repo/node_modules/puppeteer/.local-chromium/linux-809590/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory

Is there support for installing the required dependencies of puppeteer?

From what I have understood by reading Puppeteer docs, it’s supposed to run as an application (or a live script). If that’s the case indeed, I think, Netlify isn’t the service to run it on. That’s my guess, might be wrong.

I’ll update the thread if I find something else.

EDIT: As I expected, I was wrong. Turns out it is indeed possible as someone has tried it. Check here: Using Puppeteer on Netlify. Use Puppeteer to take screenshots of… | by Henrik Hauge Bjørnskov | Level Up Coding

hey there, if you run this search, you’ll see all the other posts on puppeteer in these forums:

https://answers.netlify.com/search?expanded=true&q=puppeteer

Thanks, selecting the build image ‘Ubuntu Xenial 16.04’ (which is now the default for new sites) resolved the issue.

2 Likes

Do you have Puppeteer taking a screenshot as part of the build step? Do you have an example to look at by any chance (code)? Did you have to create a build plugin?

Hey @silentfail,
Check out the article @hrishikesh linked a few posts up :arrow_up:

Thanks. Was hoping to find a more complete example (assume this has to be packaged as a plugin, wasn’t planning on using Docker, etc)? Also, am I right in thinking there’s no persistent storage on Netlify (so you couldn’t run repeated builds and save a new screenshot each time to a directory… you’d need to save it off in a S3 bucket or something)?

While we can’t provide a more specific guide, you may have more luck using the node module here: puppeteer - npm

Re: saving files, you can “abuse” our build cache to store files using plugins like this:

…but your build would STILL need to succeed if the cache isn’t there too, so better to save to an external service.

Thank you. Will look at the Puppeteer node module; in my experience (probably because of timeouts), Puppeteer seems to be very particular on Netlify. I’ve tried updating it previously without success, so might stick with an older version.