After installing puppeteer using the installation instructions in the documentation, that is by using npm install puppeteer
i try to run the example of downloading a webpage as a PDF, however whenever i try to execute the example node returns this error message:
C:\xampp\htdocs\gtsolineforms\node_modules\puppeteer-core\lib\cjs\puppeteer\node\BrowserRunner.js:299
reject(new Error([
^
Error: Failed to launch the browser process!
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
I have followed the troubleshooting guide using --disable-extentions, but it still will not work. I've tried installing chromium through npm, I have tried installing chromium on my desktop and pointing both puppeteer and puppeteer-core to it. I even tried using Microsoft's edge and their example on using puppeteer, but no matter that combination of solutions i tried this error keeps coming up.
I could not find any reference to this error anywhere that regarded windows 11 all the solutions were usually fixes for people on Linux. Is it even possible to run puppeteer on windows 11?
here is the code i was trying to execute:
const puppeteer = require('puppeteer');
//puppeteer
(async () => {
// Create a browser instance
const browser = await puppeteer.launch({
ignoreDefaultArgs: ['--disable-extensions'],
});
// Create a new page
const page = await browser.newPage();
// Website URL to export as pdf
const website_url = 'https://www.bannerbear.com/blog/how-to-download-images-from-a-website-using-puppeteer/';
// Open URL in current page
await page.goto(website_url, { waitUntil: 'networkidle0' });
//To reflect CSS used for screens instead of print
await page.emulateMediaType('screen');
// Downlaod the PDF
const pdf = await page.pdf({
path: 'result.pdf',
margin: { top: '100px', right: '50px', bottom: '100px', left: '50px' },
printBackground: true,
format: 'A4',
});
// Close the browser instance
await browser.close();
})();