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
- Installed EB CLI you can find it here
- Configured the EB CLI make sure you setup ssh for your instances !
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 !
Discussion
Amazing!
Perfect Answer!
Thanks!!!!!!!!!!!!!!!!!!!!😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀
It worked perfectly, thanks!
Thanks for this guide - very clear. I have one question though - how can I find the executablePath where chromium was installed on elastic beanstalk ?