Puppeteer Error: Chromium revision is not downloaded

前端 未结 8 510
谎友^
谎友^ 2021-02-04 01:31

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

(node:2066) UnhandledPromiseRejectionWarning: Error: Chr

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-04 01:40

    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();
        })();
    

提交回复
热议问题