Ubuntu Install Puppeteer

Run the commands below to install Puppeteer in Ubuntu 20.04.

sudo apt update
sudo apt upgrade -y
sudo apt install -y npm
npm install puppeteer

Use the script below to test if Puppeteer was installed successfully. Let’s name the script “test.js”

const puppeteer = require('puppeteer');
async function run () {
const browser = await puppeteer.launch({
defaultViewport: {width: 1920, height: 1080}
const page = await browser.newPage();
await page.goto('https://www.google.com/search?q=bitcoin');
await page.screenshot({path: 'screenshot.png'});

To execute the file. Run

node test.js

You’ll probably hit error, complaining about missing libraries. These are all the libraries missing. Just run the below command and retest the script again.

sudo apt install -y libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxi-dev libxtst-dev libnss3 libcups2 libxss1 libxrandr2 libasound2 libatk1.0-0 libatk-bridge2.0-0 libpangocairo-1.0-0 libgtk-3-0 libgbm1

Screenshot.png should be successfully generated now.

< Back to all the stories I had written

Written by

A software engineer, a rock climbing, diving & rollerblading enthusiast, a husband, a father.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store