Setting up Puppeteer on Ubuntu 18.04 and Digital Ocean
Tags: puppeteer, digitalocean, ubuntu
Published: 2019-10-17 08:47:02

---
title: Setting up Puppeteer on Ubuntu 18.04 and Digital Ocean
published: true
date: 2019-10-14 21:50:04 UTC
tags: Puppeteer,Digital Ocean,Ubuntu
canonical_url: https://javascriptwebscrapingguy.com/setting-up-puppeteer-on-ubuntu-18-04-and-digital-ocean/
---

This is a tutorial on how to set up [Puppeteer](https://github.com/GoogleChrome/puppeteer) to work on Ubuntu 18.04 using a [Digital Ocean](https://m.do.co/c/b74be0171027) droplet. While I will be going through specific steps for [Digital Ocean](https://m.do.co/c/b74be0171027), most of these steps should work great for any web server or just Ubuntu linux box.

This post is going to mirror closely what I wrote about [setting up puppeteer on Ubuntu 16.04](https://javascriptwebscrapingguy.com/setting-up-puppeteer-on-ubuntu-16-04-and-digital-ocean/).

Getting into it, after creating an account with [Digital Ocean](https://m.do.co/c/b74be0171027), you will want to create a new droplet. A droplet in this case is just a VM where you can setup whatever you’d like. When you select it, you should come to this screen. For our purposes, we can use the smallest droplet at only $5/mo.

![](https://javascriptwebscrapingguy.com/wp-content/uploads/2019/07/image-8-1024x618.png)

If you are unfamiliar with doing any kind of cloud hosting, one of the beauties of it is that this $5/mo is the cost if you leave the droplet running all month. You can also scale up the power at any time. This is ideal for the purposes of web scraping. If we are just scraping something daily for like 10 – 15 minutes, we can just spin up the droplet for that time and then spin it down when we are done. It’s pretty great and makes it super economical.

I really feel that using an ssh key is the way to go for accessing your droplet. It’s a lot more secure and quicker since you don’t have to enter your password each time. I’m not going to go into how to do it here but Digital Ocean has a [great article walking through it](https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-ubuntu-1604).

![](https://javascriptwebscrapingguy.com/wp-content/uploads/2019/07/image-9-1024x132.png)

We will use a bash terminal to connect via ssh to our newly formed droplet. There are some various basic server setup that is recommended and [Digital Ocean has another great article here about it.](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04)

![](https://javascriptwebscrapingguy.com/wp-content/uploads/2019/07/image-10.png)<figcaption>Cloning the repo</figcaption>

Using the [Citadel packaging integration test](https://www.citadelpackaging.com/) example because I know it contains some good puppeteer testing, we clone it with `git clone git@github.com:aarmora/jordan-does-integration-tests-on-citadel-packaging.git`.

I’m now going to install node.js on this droplet so we can take advantage of all of the javascript that we need to get this going. Digital Ocean has [yet another article on how to do this](https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04). The necessary commands you will need to run, however, are the following:

```
sudo apt-get update
sudo apt-get install build-essential libssl-dev

curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh -o install_nvm.sh

bash install_nvm.sh
source ~/.profile

nvm install 10
```

This will install node version 10.16.0. You can verify it by running `node -v`. From here we just go into our scraper directory and run `npm i`.

Now if we were on a windows (and probably mac?) machine, we’d be good to go. Running even our `npm run start:ubuntu` which should run Puppeteer ready for ubuntu will still throw something like the following error:

![](https://javascriptwebscrapingguy.com/wp-content/uploads/2019/07/image-12.png)

You will need to install some additional depedencies:

```
sudo apt-get install libx11-xcb1 libxcomposite1 libxi6 libxext6 libxtst6 libnss3 libcups2 libxss1 libxrandr2 libasound2 libpangocairo-1.0-0 libatk1.0-0 libatk-bridge2.0-0 libgtk-3-0
```

and then you should be good to go! Puppeteer is working like a charm!

![](https://javascriptwebscrapingguy.com/wp-content/uploads/2019/07/image-13.png)

The post [Setting up Puppeteer on Ubuntu 18.04 and Digital Ocean](https://javascriptwebscrapingguy.com/setting-up-puppeteer-on-ubuntu-18-04-and-digital-ocean/) appeared first on [JavaScript Web Scraping Guy](https://javascriptwebscrapingguy.com).