PRICING
PRODUCT
SOLUTIONS
by use cases
AI Lead ManagementInvoicingSocial MediaProject ManagementData Managementby Industry
learn more
BlogTemplatesVideosYoutubeRESOURCES
COMMUNITIES AND SOCIAL MEDIA
PARTNERS
Want to automate Chrome or Chromium with ease? Puppeteer is a Node.js library that simplifies browser automation, perfect for tasks like testing and scraping. Here's what you'll learn:
npm i puppeteer
(includes Chrome for Testing) or npm i puppeteer-core
(use your own browser).
Before we share a complete guide on issues in configuring Puppeteer, you should know that you can just skip it and use a direct, ready-made integration node on Latenode! Check it out:
Latenode works seamlessly with Puppeteer to simplify browser automation. Below, we’ll explore Latenode's features and how to use a direct integration with Puppeteer for your automation needs.
Here’s a breakdown of Latenode’s main features:
Feature | Description | Benefit |
---|---|---|
Headless Browser | Puppeteer library integration | Direct browser control |
AI Code Assistant | Automated code generation | Speeds up debugging and coding |
No-code flexibility | 300+ no-code integrations for tailored workflow adjustments | Extends Puppeteer functionality |
NPM Package Support | Access to over 1 million packages | Boosts automation capabilities |
"What I liked most about Latenode compared to the competition is that I did have the ability to write code and create custom nodes." - Germaine H., Founder Information Technology
Latenode offers integration with the Headless Browser node, which is based on Puppeteer and allows you to add code directly into the editor and use it for tasks such as scraping all available information from a website, taking screenshots of pages, filling out forms, and generally anything that Puppeteer supports.
To find this integration, simply navigate to the Code Integrations folder in the node library, where you'll find the Headless Browser node. Add it to your script, click on it, and an editor will open where you can add code of any complexity and length. Additionally, you can specify the address, login, and password of your Proxy in the settings.
But one node is not enough for automation. For greater customization, add a trigger and another action. For example, a webhook trigger and response to monitor exchange rate changes at the Bank of England, as we show in the guide above. Here's a scenario:
SCENARIO
"Latenode blows away the competition with 99% uptime, affordable execution-based pricing, and a user-friendly interface." - Hammad Hafeez
Latenode’s pricing is based on execution time rather than individual tasks, making it a budget-friendly option for large-scale Puppeteer automation. This platform allows developers to focus on creating robust workflows without worrying about excessive costs.
To maximize efficiency, you can use Latenode's интеграцию с Javascript, а также более чем 300 интеграциями с базами данных, CRM, project management tools, and AI models like Claude, ChatGPT, and Gemini. There’s a lot of potential usecases: automated outreach, database management, web scraping, etc. By combining Latenode and Puppeteer, you can centralize and streamline your automation processes.
If you still want a guide on fixing Puppeteer problems, check out the breakdown below.
Before installing Puppeteer, make sure your setup meets the necessary dependencies to ensure smooth installation and operation.
Puppeteer requires Node.js to run. The latest versions of Puppeteer work with Node.js version 18 or higher, which aligns with the current LTS release.
To check your Node.js version, use this command:
node --version
If your version is below 18, update Node.js before continuing. Using the latest LTS version is strongly recommended. After confirming your Node.js version, check your system's operating system requirements.
The system requirements for Puppeteer depend on the operating system you're using. Here's a quick overview:
Operating System | Architecture | Required Components | Approx. Download Size |
---|---|---|---|
Windows | x64 | Chrome for Testing | ~280MB |
macOS | x64, arm64 | Chrome for Testing | ~170MB |
Debian/Ubuntu | x64 | Chrome for Testing + Libraries | ~282MB |
When installing Puppeteer, it will automatically download a compatible version of Chrome for Testing. The download size varies depending on your OS (~280MB for Windows, ~170MB for macOS, and ~282MB for Debian/Ubuntu Linux).
For Linux users, particularly on Debian/Ubuntu, you’ll need to install some additional libraries. Use the following command:
apt-get install -y libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxi6 libxtst6 libnss3 libcups2 libxss1 libxrandr2 libasound2 libatk1.0-0 libgtk-3-0
Here are some extra tips for specific environments:
Once you've confirmed your Node.js setup and system requirements, you can install Puppeteer using npm.
You have two ways to install Puppeteer through npm:
npm i puppeteer
npm i puppeteer-core
With the standard installation, Chrome for Testing and the chrome-headless-shell
binary are downloaded to $HOME/.cache/puppeteer
. Check the System Requirements section for details on download sizes.
Once installed, you're ready to test your setup.
Start by creating a file named test.js
and add the following script:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://www.google.com');
console.log('Page title:', await page.title());
await browser.close();
})();
Run the script with:
node test.js
If the script runs successfully and displays the page title, your installation is working correctly.
PUPPETEER_CACHE_DIR
environment variable to point to the correct installation directory.
"Running without a sandbox is strongly discouraged. Consider configuring a sandbox instead."
For better stability and easier maintenance, you can create a .puppeteerrc.cjs
file to configure Puppeteer's behavior instead of passing arguments directly to the launch
method.
Chromium problems often stem from missing libraries or incorrect settings.
If you'd rather use an existing Chromium installation instead of downloading a new one, Puppeteer can be set up to work with your local browser. This method is helpful if you need a specific Chromium version or handle browser installations manually.
To link Puppeteer with your local Chromium, adjust your launch settings like this:
const browser = await puppeteer.launch({ executablePath: '/usr/bin/chromium-browser' });
Make sure all necessary libraries are installed. On Linux, you can identify missing libraries with:
ldd chrome | grep not
If using a local installation isn't an option, consider installing Chromium separately using the steps below.
Starting with Puppeteer v20.0.0, Chrome for Testing is downloaded instead of Chromium.
Compatibility Overview:
Puppeteer Version | Browser Version | Download Size |
---|---|---|
v24.4.0 | Chrome for Testing 134.0.6998.35 | ~170MB (macOS) |
v24.3.1 | Chrome for Testing 133.0.6943.141 | ~282MB (Linux) |
v24.3.0 | Chrome for Testing 133.0.6943.126 | ~280MB (Windows) |
If you encounter a "Failed to launch chrome" error, try these fixes:
sudo apt-get install -y libasound2 libatk1.0-0 libgbm-dev
/dev/shm
size or use the --disable-dev-shm-usage
flag:
const browser = await puppeteer.launch({
args: ['--disable-dev-shm-usage']
});
await page.setDefaultNavigationTimeout(60000); // 60 seconds
"Headless chrome(-ium) needs a lot of dependencies to work with, and puppeteer doesn't install them all." - savebreach.com
For environments like GitLab CI or cases where sandboxing is disabled (not recommended), include specific launch arguments:
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
To bypass HTTPS-related warnings in recent Chrome versions, disable the HttpsFirstBalancedModeAutoEnable feature:
const browser = await puppeteer.launch({
args: ['--disable-features=HttpsFirstBalancedModeAutoEnable']
});
Managing dependencies effectively is crucial to avoid launch failures and unpredictable behavior. This section covers resolving version conflicts and keeping packages updated to prevent runtime errors.
Package conflicts often lead to errors like "Cannot find module 'puppeteer-core/internal/...'" or Chrome launch issues. Here's how to address these problems:
// Example: Resolving version conflicts using package.json overrides
{
"overrides": {
"ws": "^8.17.1",
"debug": "^4.3.4"
}
}
Steps to troubleshoot:
--disable-extensions
flag. Try launching without it:
const browser = await puppeteer.launch({
ignoreDefaultArgs: ['--disable-extensions']
});
Once conflicts are resolved, update your packages to ensure continued stability.
Regularly updating dependencies reduces security risks and ensures compatibility. Here's how to manage this process:
Use a simple table to monitor package versions, update dates, and their importance:
Package | Current Version | Last Updated | Required By |
---|---|---|---|
puppeteer | 24.4.0 | Mar 2024 | Core functionality |
ws | 8.17.1 | Feb 2024 | WebSocket support |
debug | 4.3.4 | Jan 2024 | Logging system |
When updating, use semantic versioning ranges carefully. For critical dependencies, pin exact versions to avoid unexpected changes:
{
"dependencies": {
"puppeteer": "24.4.0",
"puppeteer-core": "24.4.0"
}
}
Generate a detailed dependency report with:
npm list --all > dependency-report.txt
This report helps identify conflicts and problematic nested dependencies.
For environments like Docker or GitLab CI, ensure your configuration includes necessary system packages:
RUN apt-get update && apt-get install -y \
chromium \
libnss3 \
libgconf-2-4 \
libxss1
Fine-tune Puppeteer for advanced setups with these additional configurations.
Environment variables let you adjust Puppeteer's behavior and override default settings.
Here are some key variables:
Variable | Purpose | Example Value |
---|---|---|
PUPPETEER_CACHE_DIR | Specifies a custom cache directory for browser downloads | /usr/local/cache/puppeteer |
PUPPETEER_EXECUTABLE_PATH | Points to a specific browser executable | /usr/bin/chromium |
HTTP_PROXY | Configures HTTP proxy settings | http://proxy.company.com:8080 |
HTTPS_PROXY | Configures HTTPS proxy settings | https://proxy.company.com:8443 |
NO_PROXY | Lists domains excluded from proxy use | localhost,127.0.0.1 |
For custom Chromium installations, define the executable path like this:
const browser = await puppeteer.launch({
executablePath: process.env.PUPPETEER_EXECUTABLE_PATH || puppeteer.executablePath()
});
Once environment variables are set, you can configure proxies to handle network restrictions effectively.
To use a proxy server with Puppeteer, apply the following setup:
// Launch Puppeteer with a proxy server and authentication
const browser = await puppeteer.launch({
args: ['--proxy-server=http://157.230.255.230:8118']
});
await page.authenticate({
username: 'proxyUser',
password: 'proxyPass'
});
// Optimize navigation with specific settings
await page.goto('https://example.com', {
waitUntil: 'networkidle2',
timeout: 30000
});
Include error handling to ensure robust performance in production:
try {
await page.goto(url);
} catch (error) {
console.error('Proxy connection failed:', error.message);
// Add fallback logic or retry mechanism
}
For corporate setups, export proxy settings in your terminal:
export HTTP_PROXY="http://proxy.company.com:8080"
export HTTPS_PROXY="https://proxy.company.com:8443"
export NO_PROXY="localhost,127.0.0.1,.company.internal"
You can also validate proxy connections programmatically:
const validateProxy = async (page) => {
try {
await page.goto('https://api.ipify.org?format=json');
const content = await page.content();
return content.includes('ip');
} catch {
return false;
}
};
This ensures your proxy setup is working correctly before proceeding.
Before starting with Puppeteer automation, make sure your environment is configured correctly. Use the script below to validate your setup:
// Validation script for environment setup
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.validateEnvironment(); // Custom validation
await browser.close();
Setup Component | Verification Step | Common Issue |
---|---|---|
Node.js | Check version compatibility | Outdated Node.js version |
Package.json | Verify "type": "module" entry | ES6 import errors |
Chrome Installation | Test browser launch | Missing Chromium binary |
Memory Settings | Check /dev/shm size in Docker | Browser crash on launch |
Resource Management | Implement browser.close() | Memory leaks |
Once your setup is verified, you can focus on improving your workflows for better automation results.
Carriyo’s PDF system efficiently handled 10,000 shipment labels daily, achieving a p95 latency of 365ms. To reach similar performance levels, consider these strategies:
const browser = await puppeteer.launch({
headless: true,
args: ['--disable-dev-shm-usage'],
defaultViewport: { width: 1920, height: 1080 }
});
For more advanced automation, explore Latenode’s low-code workflow platform. It offers execution-based pricing and a range of features to simplify complex Puppeteer implementations.