From 26fa363443b5929e25ae39c38a7627513928b887 Mon Sep 17 00:00:00 2001 From: "Aravind.H.U" Date: Fri, 22 Jan 2021 13:55:35 +0530 Subject: [PATCH] docs(troubleshooting): describe EC2 Amazon-Linux setup (#6771) Co-authored-by: Mathias Bynens --- docs/troubleshooting.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index ccb6514dcad2f..ccb4a8f803ffd 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -17,6 +17,7 @@ * [Running Puppeteer on Google Cloud Functions](#running-puppeteer-on-google-cloud-functions) * [Running Puppeteer on Heroku](#running-puppeteer-on-heroku) * [Running Puppeteer on AWS Lambda](#running-puppeteer-on-aws-lambda) + * [Running Puppeteer on AWS EC2 instance running Amazon-Linux](#running-puppeteer-on-aws-ec2-instance-running-amazon-linux) - [Code Transpilation Issues](#code-transpilation-issues) @@ -415,6 +416,24 @@ AWS Lambda [limits](https://docs.aws.amazon.com/lambda/latest/dg/limits.html) de - https://github.com/alixaxel/chrome-aws-lambda (kept updated with the latest stable release of puppeteer) - https://github.com/adieuadieu/serverless-chrome/blob/master/docs/chrome.md (serverless plugin - outdated) +### Running Puppeteer on AWS EC2 instance running Amazon-Linux + +If you are using an EC2 instance running amazon-linux in your CI/CD pipeline, and if you want to run Puppeteer tests in amazon-linux, follow these steps. + +1. To install Chromium, you have to first enable `amazon-linux-extras` which comes as part of [EPEL (Extra Packages for Enterprise Linux)](https://aws.amazon.com/premiumsupport/knowledge-center/ec2-enable-epel/): + + ```sh + sudo amazon-linux-extras install epel -y + ``` + +1. Next, install Chromium: + + ```sh + sudo yum install -y chromium + ``` + +Now Puppeteer can launch Chromium to run your tests. If you do not enable EPEL and if you continue installing chromium as part of `npm install`, Puppeteer cannot launch Chromium due to unavailablity of `libatk-1.0.so.0` and many more packages. + ## Code Transpilation Issues If you are using a JavaScript transpiler like babel or TypeScript, calling `evaluate()` with an async function might not work. This is because while `puppeteer` uses `Function.prototype.toString()` to serialize functions while transpilers could be changing the output code in such a way it's incompatible with `puppeteer`.