Ravi Prakash SIngh
Ravi Prakash SIngh

Reputation: 13

Puppeteer is failing to launch the browser in local

I am getting this error again and again while launching the application. I would have reinstalled puppeteer for like 8-9 times and even downloaded all the dependencies listed in the Troubleshooting link.

Error: Failed to launch the browser process! spawn /home/......./NodeJs/Scraping/code3/node_modules/puppeteer/.local-chromium/linux-756035/chrome-linux/chrome ENOENT

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

This Code is just for taking a screenshot of google.com NodeJs Version- 14.0.0 Puppeteer Version- 4.0.1 Ubuntu Version- 20.04 I am using puppeteer which is bundled with Chromium

const chalk = require("chalk");
// MY OCD of colorful console.logs for debugging... IT HELPS
const error = chalk.bold.red;
const success = chalk.keyword("green");
(async () => {
    try {
        // open the headless browser
        var browser = await puppeteer.launch({ headless: false });
        // open a new page
        var page = await browser.newPage();
        // enter url in page
        await page.goto(`https://www.google.com/`);
        // Google Say Cheese!!
        await page.screenshot({ path: "example.png" });
        await browser.close();
        console.log(success("Browser Closed"));
    } catch (err) {
        // Catch and display errors
        console.log(error(err));
        await browser.close();
        console.log(error("Browser Closed"));
    }
})(); ```



Upvotes: 1

Views: 17488

Answers (1)

theDavidBarton
theDavidBarton

Reputation: 8841

As you said puppeteer 2.x.x works for you perfectly but 4.x.x doesn't: it seems to be a linux dependency issue which occurs more since puppeteer 3.x.x (usually libgbm1 is the culprit).

If you are not sure where is your chrome executable located first run:

whereis chrome

(e.g.: /usr/bin/chrome)

Then to find your missing dependencies run:

ldd /usr/bin/chrome | grep not

sudo apt-get install the listed dependencies.

After this happened you are able to do a clean npm install on your project with the latest puppeteer aas well (as of today it will be 5.0.0).

Upvotes: 1

Related Questions