Back

Could not find Chrome, deploying puppeteer using appwrite function

  • 0
  • Functions
Abhi
6 Jun, 2024, 15:14

I was trying to make a simple appwrite function that scrapes a few pages from some websites and return the result in pdf format using puppeteer. I created the function, and also deployed it but while testing I am getting this error

TypeScript
 1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome`) or
 2. your cache path is incorrectly configured (which is: /root/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.``` 

From what I could understand and research about it, it seems like an error from puppeteer side but I wasn't getting this while locally running it so do I need to configure my function in some way that it would work while using appwrite functions.
TL;DR
Developers are having trouble deploying Puppeteer with Appwrite functions due to the lack of Chrome in Alpine Linux. A solution is to manually install the Chromium package within the function. Check out an example at https://github.com/dishwasher-detergent/screenshot/blob/main/functions/screenshot/src/main.ts . The error message indicates Chrome (ver. 125.0.6422.78) could not be found, suggesting a missing installation or incorrect cache path configuration.
Kenny
6 Jun, 2024, 15:35

The functions are ran on apline linux, installing puppeteer via npm does not install chrome for alpine so you'll have to handle that yourself.

One way I got around that was installing the chromium package myself in the function and using that. You can see an example here:

https://github.com/dishwasher-detergent/screenshot/blob/main/functions/screenshot/src/main.ts

I'm not sure if anything has changed since I worked on this, but I've tried setting up the build command to install chrome and move it to the correct folder so it gets copied into the new alpine instance that is created for the function but could never get everything chromium needed moved over and working so I fell back to doing it this way.

Abhi
6 Jun, 2024, 15:38

ah okay, I will try doing the same 👍

Kenny
6 Jun, 2024, 15:39

lmk if that works for you :)

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more