Puppeteer Error: Chromium revision is not downloaded

前端 未结 8 506
谎友^
谎友^ 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();
        })();
    
    0 讨论(0)
  • 2021-02-04 01:40

    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.

    0 讨论(0)
  • 2021-02-04 01:44

    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
    
    0 讨论(0)
  • 2021-02-04 01:45

    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

    0 讨论(0)
  • 2021-02-04 01:46

    If someone still facing this problem again. Then goto node_modules folder then into puppeteer and in lib where you find launch.js open the same file and search for executablepath then change its null value to your chrome or chromium desired path.

    For me the path as follows :

    /home/Nightwing/node_modules/puppeteer/Launcher.js

    0 讨论(0)
  • 2021-02-04 01:51

    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']
        });
    
    0 讨论(0)
提交回复
热议问题