node.jsnpmchromiumpuppeteer

Puppeteer Error: Chromium revision is not downloaded


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.


Solution

  • 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