Puppeteer Error: Chromium revision is not downloaded

57,417

Solution 1

After many attempts I finally found the answer here:

sudo npm install puppeteer --unsafe-perm=true --allow-root

As @vsync pointed out, this only works for linux

Solution 2

I only managed to fix the issue by manually installing Chromium after much searching and trying most of the suggestions:

node node_modules/puppeteer/install.js

Solution 3

By default, the puppeteer module will run its install script (node install.js). However, in my case, I enabled ignore-scripts=true in my ~/.npmrc file, so it was never executed.

In that case, you have to run the command yourself:

node node_modules/puppeteer/install.js

To check: node_modules/puppeteer/.local-chromium/linux-<your_chrome_version>/ should exist now.

Solution 4

for linux:

1- you must have installed chromium browser using this command :

$sudo apt install -y chromium-browser

2- you have to get the excutable path of chromium using this command :

$which chromium-browser

3-put the executable path as an argument to the launch function :

   const puppeteer = require('puppeteer-core');
   (async () => {
   const browser = await puppeteer.launch({
   executablePath: '/usr/bin/chromium-browser',
   headless: false
    });
    const page = await browser.newPage();
    await page.goto('https://google.com');
    await page.screenshot({path: 'example.png'});

    await browser.close();
    })();

Solution 5

Confirming solutions presented here almost work. Here's my setup. Ubuntu 16.

Install chromium browser from command line then:

    const browser = await puppeteer.launch({
        executablePath: "/usr/bin/chromium-browser",
        args: ['--no-sandbox']
    });
Share:
57,417

Related videos on Youtube

Moses Schwartz
Author by

Moses Schwartz

{profile.about_text}

Updated on December 20, 2021

Comments

  • Moses Schwartz
    Moses Schwartz over 2 years

    I used npm i puppeteer as stated in the Documentation and I'm getting the following error:

    (node:2066) UnhandledPromiseRejectionWarning: Error: Chromium revision is not downloaded. Run "npm install" or "yarn install" at Launcher.launch

    when im trying this example (also from the docs):

    const puppeteer = require('puppeteer');
    (async () => {
      const browser = await puppeteer.launch();
      const page = await browser.newPage();
      await page.goto('https://example.com');
      await page.screenshot({path: 'example.png'});
      await browser.close();
    })();
    

    Also in the documentation:

    Note: When you install Puppeteer, it downloads a recent version of Chromium (~170MB Mac, ~282MB Linux, ~280MB Win) that is guaranteed to work with the API.

    Any help would be appreciated.

  • vsync
    vsync almost 5 years
    This answer is specifically for linux, which makes it useless for many developers, because windows OS is still very dominant
  • Anastasios Moraitis
    Anastasios Moraitis almost 5 years
    But ubuntu bash for windows is what will make it usefull
  • Moses Schwartz
    Moses Schwartz over 4 years
    @tramada Still Linux ;)
  • smoore4
    smoore4 about 4 years
    This was very helpful. Finally had some progress after reading this!
  • Matthew Barbara
    Matthew Barbara over 3 years
    This solution fixed my problem. Thanks!
  • Hamid Shoja
    Hamid Shoja about 3 years
    If the folder exist you can check the path, and files, or you can rename it and do the steps.
  • Mike Smith
    Mike Smith about 3 years
    My local modules had puppeteer-core instead of puppeteer but the solution worked the same.
  • eemelipa
    eemelipa about 3 years
    npm v7 does not have --unsafe-perm or equivalent anymore github.com/npm/feedback/discussions/121