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 anindex.js file:
index.js
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.json3
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
Chrome crashed or failed to launch
Chrome crashed or failed to launch
- 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
Timeout errors
Timeout errors
- Increase the timeout in
page.goto()options - Use
waitUntil: 'networkidle2'for dynamic pages
Out of memory
Out of memory
- Close browser instances after each task
- Increase
MEMORYin your config - Avoid keeping multiple pages open