New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

puppeteer-chromium-resolver

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puppeteer-chromium-resolver

Tool to resolve puppeteer and chromium faster, detect local installed chromium, download chromium with custom mirror host, cache chromium revision out of node_modules, test chromium headless being launchable.

  • 15.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
36K
decreased by-26.37%
Maintainers
1
Weekly downloads
 
Created
Source

Puppeteer Chromium Resolver

Tool to resolve puppeteer and chromium faster, detect local installed chromium, download chromium with custom mirror host, cache chromium revision out of node_modules, test chromium headless being launchable.

npm npm

  • Tool to customize puppeteer
  • Detect local chromium automatically
  • Download chromium from custom mirror host
  • Cache chromium to local folder
  • Try launching chromium and resolve launchable and version
  • Resolve chromium executablePath and puppeteer

Install

npm install puppeteer-chromium-resolver --save

Usage

[Async] dynamic detection and downloading chromium

(async () => {
    const PCR = require("puppeteer-chromium-resolver");
    const option = {
        revision: "",
        detectionPath: "",
        folderName: ".chromium-browser-snapshots",
        defaultHosts: ["https://storage.googleapis.com", "https://npm.taobao.org/mirrors"],
        hosts: [],
        cacheRevisions: 2,
        retry: 3,
        silent: false
    };
    const stats = await PCR(option);
    const browser = await stats.puppeteer.launch({
        headless: false,
        args: ["--no-sandbox"],
        executablePath: stats.executablePath
    }).catch(function(error) {
        console.log(error);
    });
    const page = await browser.newPage();
    await page.goto("https://www.npmjs.com/package/puppeteer-chromium-resolver");
    await browser.close();
})();

[Sync] chromium will be pre-downloaded when PCR installation, so calling getStats() will get PCR stats from previous installation.

const PCR = require("puppeteer-chromium-resolver");
const stats = PCR.getStats();
if (stats) {
    stats.puppeteer.launch({
        headless: false,
        args: ["--no-sandbox"],
        executablePath: stats.executablePath
    }).then(function(browser){
        //...
    }).catch(function(error) {
        console.log(error);
    });
}

Option from root package.json with "pcr" object

{
    "name": "",
    "version": "",
    "dependencies": {},

    "pcr": {
        "revision": "869685"
    }

}

Return Stats

PropertyType
revisionStringcurrent chromium revision
executablePathStringchromium executable path
folderPathStringchromium folder path
localBooleanexists local chromium
urlStringchromium download url
launchableBooleanchromium launchable
chromiumVersionStringchromium version
puppeteerVersionStringpuppeteer version
puppeteerObjectpuppeteer module

How to make puppeteer work with puppeteer-chromium-resolver

  • 1, Stop the automatic download of Chromium with following settings in .npmrc
puppeteer_skip_download = true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = true

(one more setting for puppeteer v2.x)

  • 2, Sets env PUPPETEER_EXECUTABLE_PATH to PCR executablePath globally or pass in launch option executablePath
(async () => {

    const PCR = require("puppeteer-chromium-resolver");
    const puppeteer = require("puppeteer");
    const stats = await PCR();
    //update global env
    process.env.PUPPETEER_EXECUTABLE_PATH = stats.executablePath;

    //or specify executablePath
    const browser = await puppeteer.launch({
        executablePath: stats.executablePath,
        headless: false
    });

})();

CHANGELOG

major version following puppeteer-core

  • v15.0.0

    • updated puppeteer-core to ^15.0.0
  • v14.0.0

    • updated puppeteer-core to ^14.0.0
  • v12.0.0

    • updated puppeteer-core to ^12.0.1
  • v11.0.0

    • updated puppeteer-core to ^11.0.0
  • v10.0.0

    • updated puppeteer-core to ^10.0.0
  • v9.0.0

    • updated puppeteer-core to ^9.1.1
  • v8.1.1

    • supported reading option from root package.json with "pcr" object
    • updated PCR(option) API to support using stats cache
  • v8.0.0

    • updated puppeteer-core to v8.0.0
  • v7.0.0

    • updated puppeteer-core to v7.1.0
  • v5.2.0

    • updated puppeteer-core to v5.2.1
  • v5.0.1

    • updated puppeteer-core to v5
    • added sync API getStats()
  • v4.0.0

    • updated puppeteer-core to v4
  • v3.2.0

    • updated puppeteer-core to v3
  • v3.1.0

    • updated puppeteer-core version to 2.1.1
    • auto detect host response time and download from quicker one
  • v3.0.1

  • v2.0.2

    • added option cacheRevisions to cache multiple revisions
  • v3.0.0

    • updated puppeteer-core version to v2.0.0
  • v2.0.1

    • updated puppeteer-core version to v1.19.0
    • refactoring with async/await
    • fixed requesting timeout
  • v1.0.12

    • updated puppeteer-core version to v1.18.1
    • fixed a gauge log issue

FAQs

Package last updated on 29 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc