Skip to main content

Introduction

Puppeteer is a Node.js library that provides a high-level API to control Chrome/Chromium. This guide covers deploying Puppeteer scripts on Shard Cloud.

Creating Your Project

Ensure you have Node.js and npm installed.

Installing Dependencies

Basic Puppeteer Script

Create an index.js file:
index.js
The --no-sandbox and --disable-setuid-sandbox flags are required for Puppeteer to work in containerized environments.

Package.json Configuration

package.json

Shard Cloud Configuration

Create a .shardcloud file:
.shardcloud
Puppeteer applications require at least 512MB-1024MB of memory due to the browser overhead.

Continuous Screenshot Example

index.js

Web Scraping Example

scraper.js

PDF Generation Example

pdf.js

Deploying

1

Prepare Your Files

Ensure you have:
  • index.js (or your script)
  • package.json
  • .shardcloud
2

Exclude Unnecessary Files

Remove: node_modules/, package-lock.json
3

Create ZIP Archive

Compress your project folder.
4

Upload to Shard Cloud

Go to Shard Cloud Dashboard and upload.

Accessing Output Files

Screenshots and PDFs saved by your script can be downloaded from Shard Cloud’s file manager in the dashboard.

Additional Resources

Troubleshooting

  • Ensure headless mode is enabled
  • Add all required flags (--no-sandbox, --disable-setuid-sandbox, --disable-dev-shm-usage)
  • Increase memory allocation to at least 1024MB
  • Increase the timeout in page.goto() options
  • Use waitUntil: 'networkidle2' for dynamic pages
  • Close browser instances after each task
  • Increase MEMORY in your config
  • Avoid keeping multiple pages open