Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Failed to launch the browser process puppeteer

Tags:

checked failed crashForExceptionInNonABIComplianceCodeRange the code below its functon is to create PDF file

   (async function() {        try {        const browser = await puppeteer.launch();       const page = await browser.newPage();        await page.setContent(pdfOutput);       await page.emulateMedia("screen");       await page.pdf({         path: "routes/planiton/pdf/mypdf.pdf",         format: "A4",         printBackground: true       });        console.log('done');       await browser.close();       //process.exit();      } catch (e) {       console.log("Our Error", e)     }   })(); 
like image 950
Abu Dujana Mahalail Avatar asked Jan 30 '20 04:01

Abu Dujana Mahalail


People also ask

How do I open a browser using puppeteer?

To use Puppeteer with a different version of Chrome or Chromium, pass in the executable's path when creating a Browser instance: const browser = await puppeteer.

Can puppeteer use Chrome instead of Chromium?

Puppeteer is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome or Chromium. An explanation of what Puppeteer is and the things it can do.

Does puppeteer work on Windows?

If you have Microsoft Edge installed, you can use puppeteer-core. puppeteer-core is a lightweight version of Puppeteer that launches an existing browser installation, like Microsoft Edge. To download Microsoft Edge, go to Download Microsoft Edge Insider Channels. Puppeteer is a Node library.

What browsers does puppeteer support?

Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.


2 Answers

I had the same issue, I tried everything which is listed from the Puppeteer guide, none of them worked for me.

What works for me was to download chromium manually sudo apt-get install chromium-browser.

And then, tell Puppeteer where chromium is located :

const browser = await puppeteer.launch({   executablePath: '/usr/bin/chromium-browser' }) 

Hope this will help someone :)

like image 142
JULIEN PICARD Avatar answered Sep 18 '22 06:09

JULIEN PICARD


const browser = await puppeteer.launch({     headless:false,     args: ["--no-sandbox"] }); 

install puppeteer and puppeteer-core.

like image 39
Mohammadreza Abdoli Avatar answered Sep 17 '22 06:09

Mohammadreza Abdoli