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