Skip to content

Instantly share code, notes, and snippets.

@tavinus
Created September 11, 2020 09:14
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tavinus/7effd4b3dac87cb4366e3767679a192f to your computer and use it in GitHub Desktop.
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.

@RitvikSardana
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

@tavinus
Copy link
Author

tavinus commented Jul 11, 2022

Can u run the test code? What code are you currently running? If you post the code with the error message, it is easier to guess. Permission errors are easy to solve, but out of scope in this case...I suggest you learn that (it is really really easy in linux/unix).

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