Installing Puppeteer on DigitalOcean: A Guide for Web Scraping and Automation

Atakan Demircioğlu
3 min readJun 1, 2023

--

My notes about installing puppeteer to digital ocean droplet.

How to install Puppeteer?

As a first step, install Puppeteer and Chromium browser to your droplet.

sudo npm install -g puppeteer - unsafe-perm=true -allow-root 
sudo apt install chromium-browser -y
  • sudo is a command used in Unix-like operating systems to run a command with administrative or root privileges. It allows the user to perform tasks that require elevated permissions.
  • npm is the package manager for Node.js, a JavaScript runtime. It is used to install, manage, and update packages and dependencies for Node.js projects.
  • install is an npm command used to install packages.
  • -g flag stands for "global" and is used to install the package globally, making it accessible from any location in the system.
  • puppeteer is a Node.js library that provides a high-level API for controlling headless Chrome or Chromium browsers. It allows you to automate and interact with web pages programmatically.
  • -unsafe-perm=true flag sets the unsafe-perm option to true, which allows the installation to proceed with the current user's permissions, even if they are considered unsafe.
  • -allow-root flag allows the installation to run with root permissions, overriding any security checks that prevent installing packages as the root user.

After that probably you will get some errors. For fixing this error install whole dependencies.

How to install dependencies?

For installing related puppeteer dependencies, just enter the following comment to your CLI.

sudo apt update && sudo apt install -y gconf-service libgbm-dev libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

How to run puppeteer code?

After the installation, there are a few things to pay attention to.

 const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox']
});

Do not forget to add these args to the puppeteer launch settings. Also, you need to set the headless as true.

Twitter: https://twitter.com/atakde

Github: https://github.com/atakde

If you like to get more updates from me, 
please follow me on Medium and subscribe to email alert.

--

--

Atakan Demircioğlu

Passionate about blogging and sharing insights on tech, web development, and beyond. Join me on this digital journey! 🚀