CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-puppeteer--browsers

Download, manage, and launch browsers (Chrome, Chromium, Firefox) and drivers (ChromeDriver) for testing and automation

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

installation.mddocs/

Browser Installation

Comprehensive browser download and installation management with support for multiple browsers, platforms, and version resolution. Handles progress tracking, archive extraction, and dependency installation.

Capabilities

Install Function

Downloads and unpacks browser archives according to InstallOptions. Provides two modes: unpacking (default) and download-only.

/**
 * Downloads and unpacks the browser archive according to InstallOptions
 * @param options - Installation configuration with unpack enabled (default)
 * @returns Promise resolving to InstalledBrowser instance
 */
function install(options: InstallOptions & {unpack?: true}): Promise<InstalledBrowser>;

/**
 * Downloads the browser archive without unpacking
 * @param options - Installation configuration with unpack disabled
 * @returns Promise resolving to absolute path of downloaded archive
 */
function install(options: InstallOptions & {unpack: false}): Promise<string>;

interface InstallOptions {
  /** Path to download browsers to */
  cacheDir: string;
  /** Target platform (auto-detected if not provided) */
  platform?: BrowserPlatform;
  /** Browser to install */
  browser: Browser;
  /** Build identifier for caching */
  buildId: string;
  /** Alias for the build ID (e.g., 'canary') */
  buildIdAlias?: string;
  /** Progress callback or 'default' for built-in progress bar */
  downloadProgressCallback?: 'default' | ((downloadedBytes: number, totalBytes: number) => void);
  /** Download host URL (uses default browser-specific URLs if not provided) */
  baseUrl?: string;
  /** Whether to unpack archives (default: true) */
  unpack?: boolean;
  /** Install system dependencies (default: false, Linux Chrome only) */
  installDeps?: boolean;
}

Usage Examples:

import { install, Browser, BrowserPlatform } from "@puppeteer/browsers";

// Install latest Chrome with default settings
const browser = await install({
  cacheDir: "./browsers-cache",
  browser: Browser.CHROME,
  buildId: "118.0.5993.70"
});

console.log("Installed at:", browser.path);
console.log("Executable:", browser.executablePath);

// Install with progress tracking
const browserWithProgress = await install({
  cacheDir: "./browsers-cache",
  browser: Browser.FIREFOX,
  buildId: "119.0",
  downloadProgressCallback: (downloaded, total) => {
    const percent = (downloaded / total * 100).toFixed(1);
    console.log(`Download progress: ${percent}%`);
  }
});

// Download archive without unpacking
const archivePath = await install({
  cacheDir: "./browsers-cache",
  browser: Browser.CHROMIUM,
  buildId: "1097615",
  unpack: false
});

console.log("Archive downloaded to:", archivePath);

Uninstall Function

Removes a specific browser installation from the cache directory.

/**
 * Uninstalls a browser from the cache directory
 * @param options - Uninstallation configuration
 */
function uninstall(options: UninstallOptions): Promise<void>;

interface UninstallOptions {
  /** Target platform (auto-detected if not provided) */
  platform?: BrowserPlatform;
  /** Path to cache directory */
  cacheDir: string;
  /** Browser to uninstall */
  browser: Browser;
  /** Build identifier to uninstall */
  buildId: string;
}

Usage Example:

import { uninstall, Browser } from "@puppeteer/browsers";

// Uninstall specific browser version
await uninstall({
  cacheDir: "./browsers-cache",
  browser: Browser.CHROME,
  buildId: "118.0.5993.70"
});

console.log("Browser uninstalled successfully");

Get Installed Browsers

Retrieves metadata about all browsers installed in the cache directory.

/**
 * Returns metadata about browsers installed in the cache directory
 * @param options - Query configuration
 * @returns Promise resolving to array of installed browser instances
 */
function getInstalledBrowsers(options: GetInstalledBrowsersOptions): Promise<InstalledBrowser[]>;

interface GetInstalledBrowsersOptions {
  /** Path to cache directory */
  cacheDir: string;
}

Usage Example:

import { getInstalledBrowsers } from "@puppeteer/browsers";

// List all installed browsers
const browsers = await getInstalledBrowsers({
  cacheDir: "./browsers-cache"
});

browsers.forEach(browser => {
  console.log(`${browser.browser}@${browser.buildId} (${browser.platform})`);
  console.log(`  Path: ${browser.path}`);
  console.log(`  Executable: ${browser.executablePath}`);
});

Can Download Check

Checks if a browser can be downloaded with the given options.

/**
 * Checks if a browser can be downloaded with given options
 * @param options - Installation configuration to check
 * @returns Promise resolving to boolean indicating download availability
 */
function canDownload(options: InstallOptions): Promise<boolean>;

Usage Example:

import { canDownload, Browser } from "@puppeteer/browsers";

// Check if browser version is available for download
const isAvailable = await canDownload({
  cacheDir: "./browsers-cache",
  browser: Browser.CHROME,
  buildId: "118.0.5993.70"
});

if (isAvailable) {
  console.log("Browser is available for download");
} else {
  console.log("Browser version not found");
}

Get Download URL

Retrieves the URL for downloading a browser binary archive.

/**
 * Retrieves URL for downloading browser binary archive
 * @param browser - Browser type
 * @param platform - Target platform
 * @param buildId - Build identifier
 * @param baseUrl - Optional base URL override
 * @returns Download URL
 */
function getDownloadUrl(
  browser: Browser, 
  platform: BrowserPlatform, 
  buildId: string, 
  baseUrl?: string
): URL;

Usage Example:

import { getDownloadUrl, Browser, BrowserPlatform } from "@puppeteer/browsers";

// Get download URL for specific browser
const url = getDownloadUrl(
  Browser.CHROME,
  BrowserPlatform.LINUX,
  "118.0.5993.70"
);

console.log("Download URL:", url.toString());

Progress Callback Factory

Creates a default progress callback function for browser downloads.

/**
 * Creates default progress callback for browser downloads
 * @param browser - Browser type
 * @param buildId - Build identifier
 * @returns Progress callback function with built-in progress bar
 */
function makeProgressCallback(
  browser: Browser, 
  buildId: string
): (downloadedBytes: number, totalBytes: number) => void;

Usage Example:

import { install, makeProgressCallback, Browser } from "@puppeteer/browsers";

// Install with default progress callback
const progressCallback = makeProgressCallback(Browser.CHROME, "118.0.5993.70");

const browser = await install({
  cacheDir: "./browsers-cache",
  browser: Browser.CHROME,
  buildId: "118.0.5993.70",
  downloadProgressCallback: progressCallback
});

Installation Process

The installation process follows these steps:

  1. Platform Detection: Automatically detects OS and architecture if not specified
  2. Download URL Resolution: Resolves appropriate download URL for browser/platform/build combination
  3. Cache Check: Checks if browser is already installed to avoid duplicate downloads
  4. Download: Downloads browser archive with optional progress tracking
  5. Extraction: Unpacks archive to cache directory (unless unpack: false)
  6. Metadata: Updates cache metadata with installation information and aliases
  7. Dependencies: Installs system dependencies if installDeps: true (Linux Chrome only)

Supported Browsers and Platforms

Browsers

  • Chrome: Chrome for Testing binaries with stable/dev/canary/beta channels
  • Chromium: Chromium snapshots from tip-of-tree builds
  • Firefox: Firefox releases including stable/nightly/devedition channels
  • Chrome Headless Shell: Headless Chrome for automation
  • ChromeDriver: WebDriver implementation for Chrome

Platforms

  • Linux: x64 and ARM64 architectures
  • macOS: Intel and Apple Silicon (ARM64) architectures
  • Windows: 32-bit and 64-bit architectures

Error Handling

Installation functions may throw errors for:

  • Network Issues: Download failures, connection timeouts
  • File System Issues: Permission errors, disk space, invalid paths
  • Platform Issues: Unsupported platform/browser combinations
  • Version Issues: Invalid build IDs, unavailable versions
  • Archive Issues: Corrupted downloads, extraction failures

Always wrap installation calls in try-catch blocks for proper error handling.

Install with Tessl CLI

npx tessl i tessl/npm-puppeteer--browsers

docs

browser-data.md

cache.md

cli.md

index.md

installation.md

launching.md

tile.json