Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Node.js first, then open a new Visual Studio Code window and integrated terminal, create a project, run npm i puppeteer, and execute a small Node script. The puppeteer package downloads a compatible Chrome for Testing browser; puppeteer-core does not. Once installed, Puppeteer can capture viewport, full-page, or element screenshots and VS Code can debug the script in place.

What you need before installing

  • Node.js and npm: VS Code is the editor, not the JavaScript runtime. Install Node.js for your operating system, then close and reopen VS Code so a fresh terminal receives the updated PATH. Microsoft’s Node tutorial documents this workflow and the integrated terminal (VS Code Node.js tutorial).
  • Visual Studio Code: Open the folder that will contain the automation project.
  • Network and disk space: Puppeteer downloads Chrome for Testing and a chrome-headless-shell. Puppeteer’s documentation gives approximate download sizes of 170 MB on macOS, 282 MB on Linux and 280 MB on Windows; these are current documentation estimates, not dated benchmarks (Puppeteer installation guide).

Verify the runtime in a new VS Code terminal:

node --version
npm --version

If either command is not recognized, install Node.js and open another VS Code window or terminal before continuing.

Create a project and install Puppeteer

  1. In VS Code, choose File → Open Folder and create or select a project directory.
  2. Open Terminal → New Terminal.
  3. If the folder has no package manifest, initialize one:
npm init -y
  1. Install the browser-managed package:
npm i puppeteer

This is the normal installation command documented by Puppeteer. The package installs the JavaScript API and downloads a compatible Chrome for Testing build. The default browser cache is under $HOME/.cache/puppeteer on macOS and Linux (the exact location can vary by platform and configuration).

When to choose puppeteer-core

Use puppeteer when each project should receive Puppeteer’s compatible browser automatically. Use puppeteer-core when your team supplies a system Chrome, a remote browser or a centrally managed binary. With puppeteer-core, you must provide a browser location or channel yourself; it does not download Chrome (package and browser-management guidance).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall

For example, a project-managed executable can be selected at launch:

import puppeteer from 'puppeteer-core';

const browser = await puppeteer.launch({
  executablePath: '/path/to/chrome'
});

Use the path appropriate to your machine or runner. Do not copy a path from another operating system.

Fix a missing browser after installation

Package managers can be configured to block dependency install scripts. If npm i puppeteer finishes but no browser is present, run:

npx puppeteer browsers install

If your package manager requires explicit approval for install scripts, allow Puppeteer’s install script and rerun the browser installation command. Changes to browser-download configuration take effect only after you rerun the browser-install command (Puppeteer configuration guide).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Write a screenshot script in VS Code

Create screenshot.mjs in the project folder. The .mjs extension enables ES module imports without changing the package manifest.

Rank #2
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
  • 1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core
  • 4GB DDR4 System Memory; 128GB Solid State Drive
  • 11.6" HD (1366 x 768) Multi-Touch Display
  • Combo headphone/microphone jack - Noble Wedge Lock slot - HDMI; 2 USB 3.1 Gen 1
  • Windows 11 Pro
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle2' });
  await page.screenshot({ path: 'screenshot.png', fullPage: true });
  console.log('Saved screenshot.png');
} finally {
  await browser.close();
}

Run it from the integrated terminal:

node screenshot.mjs

The script opens the downloaded browser, waits for navigation, writes screenshot.png in the project directory and closes the browser even if an error occurs. Puppeteer’s screenshot guide documents Page.screenshot() and the same launch, navigation and capture sequence (Puppeteer screenshots guide).

Choose a readiness condition deliberately

networkidle2 waits until there are no more than two active network connections for a short period. It works for many static pages but can stall on applications that keep analytics, sockets or polling requests open. Alternatives include:

  • waitUntil: 'domcontentloaded' for an early document-ready capture.
  • waitUntil: 'load' when page resources must finish but background requests are acceptable.
  • A selector wait for an application-specific signal:
await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
await page.waitForSelector('[data-ready="true"]', { timeout: 30000 });

Use a short explicit delay only when the site has a known animation or deferred render that cannot be represented by a selector. A delay alone is less reliable than waiting for the page’s meaningful state.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture viewport, full-page and element images

Viewport screenshot

await page.setViewport({ width: 1440, height: 900, deviceScaleFactor: 1 });
await page.screenshot({ path: 'viewport.png' });

This captures the visible viewport. Set deviceScaleFactor: 2 for a retina-style image, remembering that dimensions and file size increase.

Full-page screenshot

await page.screenshot({ path: 'full-page.png', fullPage: true });

fullPage: true captures the document’s full height. Pages that lazy-load images may need scrolling or another readiness signal first; otherwise content below the fold can be missing.

Rank #3
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.

One rendered element

const card = await page.waitForSelector('.pricing-card');
await card.screenshot({ path: 'pricing-card.png' });

Element screenshots are useful for bounded components and avoid producing a very tall image. Puppeteer also returns a Uint8Array when no path is supplied, or a Base64 string with encoding: 'base64' (Page.screenshot API).

Useful launch and page options

Need Example Why it matters
Specific Chrome binary puppeteer.launch({ executablePath: '/path/to/chrome' }) Uses a system or centrally managed browser.
Dark-mode rendering await page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: 'dark' }]); Captures the site’s dark theme when supported.
Custom viewport page.setViewport({ width: 390, height: 844, isMobile: true }) Checks responsive layouts.
HTTP headers page.setExtraHTTPHeaders({ 'Accept-Language': 'en-US' }) Reproduces a request context needed by the page.
Screenshot bytes const bytes = await page.screenshot(); Lets your code upload or transform the image without a temporary file.

Keep credentials out of source files. Use environment variables for tokens and test against sites you are authorized to automate. A custom Chrome path, proxy or sandbox setting can be supplied in launch() for your environment, but those settings are deployment-specific.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Debug Puppeteer without leaving VS Code

  1. Set a breakpoint beside page.goto, waitForSelector or screenshot.
  2. Press F5 to start the built-in Node debugger. VS Code can generate a launch.json configuration if needed.
  3. For terminal-style debugging, choose Terminal → New JavaScript Debug Terminal. Enable auto attach when you want VS Code to connect to Node processes started from its terminals.
  4. Inspect the current URL, selector results and caught exception in the Debug Console. Add logging around each wait so you know whether navigation, rendering or file output failed.

These debugger, JavaScript Debug Terminal, auto-attach and breakpoint workflows are covered in Microsoft’s Node.js debugging documentation (VS Code Node.js debugging).

Troubleshooting common failures

“node” or “npm” is not recognized

Cause: Node.js is absent or the terminal predates the PATH change. Fix: install Node.js, close the old terminal, open a new VS Code window and rerun node --version and npm --version.

“Could not find Chrome”

Cause: the browser download was skipped or blocked by package-manager policy. Fix: run npx puppeteer browsers install, then rerun the script. If scripts are disabled, explicitly permit Puppeteer’s install script and repeat the command.

Rank #4
15.6 Inch Laptop Computer, N4020, 4GB DDR4 RAM, 128GB eMMC,with Windows 11
  • EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
  • 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
  • RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
  • ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
  • LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.

Launch fails with a custom browser

Cause: executablePath points to a nonexistent binary, or the binary is incompatible with the installed Puppeteer version. Fix: verify the path and permissions, or return to puppeteer so it manages a compatible browser. After changing download configuration, rerun browser installation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The image is blank or incomplete

Cause: capture happened before the meaningful content rendered, or the page uses lazy loading. Fix: select a better waitUntil condition, wait for a visible application selector, scroll to trigger lazy images, and use fullPage: true only when the entire document is required.

Navigation times out

Cause: slow resources, long polling or a site that never reaches network idle. Fix: use domcontentloaded or load, then wait for a specific selector. Increase the navigation timeout only after choosing a realistic readiness signal.

Output is unexpectedly huge

Cause: full-page height, retina scale or large images. Fix: capture an element or viewport, reduce deviceScaleFactor, and resize the resulting image in your pipeline.

Performance, reliability and operating cost

  • Reuse browsers for batches: launch once, create a new page per URL, and close the browser after the batch. Repeated launches add startup time and disk activity.
  • Control concurrency: too many simultaneous pages can exhaust memory and trigger site defenses. Start with a small worker pool and increase it while monitoring failures.
  • Cache the browser download in CI: the Chrome for Testing download is large, so cache Puppeteer’s browser directory where your CI provider permits it.
  • Make captures deterministic: fix viewport, device scale, timezone, locale and readiness selectors; disable animations in test CSS when pixel comparison matters.
  • Plan for access controls: authenticated pages require a deliberate cookie or login flow, and bot checks may prevent a meaningful screenshot. Only automate accounts and sites you are permitted to access.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need an API response instead of maintaining a local Chrome installation, ScreenshotNeo is a website screenshot API and MCP server. It accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each cleanup step can be turned off. Only clean shots are billed: bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing, and response headers identify the page verdict and whether it was billed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

One GET request returns PNG, JPEG, WebP or a PDF. The API supports full-page and CSS-selector element captures, lazy-image loading, dark mode, device presets and arbitrary viewports, retina scale, PDF paper and page controls, custom CSS and JavaScript, pre-capture clicks, selector waits, delays or network-idle waits, request and resource blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, selectable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage reporting and an OpenAPI specification. Parameter names used by other screenshot APIs are also accepted.

Best Value
Sale
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
require('fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));

See the complete parameter reference at ScreenshotNeo documentation. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots, and every feature is available on every plan. An MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. Create a free ScreenshotNeo account to get the 1,000 monthly shots.

Frequently Asked Questions

Should I commit Puppeteer’s downloaded Chrome to Git?

No. Keep the browser cache outside the repository and install or restore it during local setup and CI provisioning.

Can I use a CommonJS script instead of .mjs?

Yes. Save the file with a .cjs extension and use const puppeteer = require('puppeteer');; the launch, navigation and screenshot calls are the same.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why does networkidle2 never finish on my site?

Persistent analytics, polling or WebSocket traffic can prevent network idle. Navigate with domcontentloaded or load, then wait for the selector that proves the page is ready.

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$249.99
Bestseller No. 2
Dell Latitude 3190 11.6' HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core; 4GB DDR4 System Memory; 128GB Solid State Drive
$179.99
Bestseller No. 3
Dell Latitude 5420 14' FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
256 GB SSD of storage.; Multitasking is easy with 16GB of RAM; Equipped with a blazing fast Core i5 2.00 GHz processor.
$289.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.