loading...
Cover image for A developers guide to Run Puppeteer on Elastic Beanstalk (no ubuntu linux)

A developers guide to Run Puppeteer on Elastic Beanstalk (no ubuntu linux)

achimoraites profile image Achilles Moraites ・1 min read

The problem with running puppeteer on elastic beanstalk is that chrome is not included by default.

This has been published on Medium

Make sure you have

Install chrome on elastic beanstalk

Connect with ssh to elastic beanstalk
To connect with ssh the easiest way is to use:

eb ssh

after you have connected, run the following command

curl https://intoli.com/install-google-chrome.sh | bash

the command above fetches and runs the installation script on elastic beanstalk.

Lets Use it

After we have chrome installed we need to setup puppeteer to use it instead of the default chromium that will not work no matter what.

here you can see a simple snippet of how we can use puppeteer to take a screenshot of a page in www.example.com , note the executablePath is pointing to the directory where our installed chrome lives.

'use strict';                                               
const puppeteer = require('puppeteer');

(async() => {

const browser = await puppeteer.launch({executablePath: '/usr/bin/google-chrome-stable',
headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox']});

const page = await browser.newPage();

await page.goto('https://www.example.com');                                                               

await page.screenshot({ path: 'screenshot.png', fullPage: true });

browser.close();

})();

Congrats you can now use Puppeteer on elastic beanstalk !

cover photo by Magda Ethels

Discussion

pic
Editor guide
Collapse
giovanigenerali profile image
Giovani Generali

It worked perfectly, thanks!

Collapse
tomgreeen profile image
tomgreeEn

Thanks for this guide - very clear. I have one question though - how can I find the executablePath where chromium was installed on elastic beanstalk ?