Skip to content

Instantly share code, notes, and snippets.

@tavinus
Created September 11, 2020 09:14
Show Gist options
  • Select an option

  • Save tavinus/7effd4b3dac87cb4366e3767679a192f to your computer and use it in GitHub Desktop.

Select an option

Save tavinus/7effd4b3dac87cb4366e3767679a192f to your computer and use it in GitHub Desktop.
Minimal Puppeteer NodeJS Debian 10 Buster

System

Debian 10 Buster headless

Chromium dependencies

Shared Libraries needed

$ sudo apt install libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libgbm1 libasound2 libpangocairo-1.0-0 libxss1 libgtk-3-0

Install nvm

Local user

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

Reconnect/Reload or load manually

Install NodeJS

nvm install node

Test Puppeteer

Create a new foler and install puppeteer

$ mkdir test && pushd test
$ npm i puppeteer # or yarn add puppeteer

Run a test program

Create a new file

$ nano test.js

Content

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({path: 'example.png'});

  await browser.close();
})();

If all went fine you will have a screenshot of the page on your current folder.

@nicolasey
Copy link

Node version is - 14.19.3 Debian version is - 10.12

I am unable to reslove this issue -

I get this error EACCES: permission denied, open './test.jpg'

I am using AWS EC2 instance,

How can I solve this error? I believe there could be some owner, group or permission error. Can you please help

It means your web user (which may be the one using puppeteer cannot access this file. Maybe consider a chown ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment