0

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();
  })();
  • could be access to the folder or executable access, try to run your terminal as admin before running the script. – Ricardo Silva Jan 24 '23 at 13:13
  • ah yeah forgot to mention that, I've tried running mingw and cmd as admin and executing the code with no success – Quarter Pie Jan 24 '23 at 13:17
  • perhaps [this](https://stackoverflow.com/a/66549119/4935162) or [this](https://stackoverflow.com/a/63137427/4935162), just point to your actual browser executable. [this](https://stackoverflow.com/a/20752358/4935162) is for chrome – Yarin_007 Jan 24 '23 at 13:26
  • Hm, i tried that using chromium, chrome, and edge. with different executable paths, using puppeteer and puppeteer-core but i keep getting the same error. I'll try running it on a different computer tomorrow. – Quarter Pie Jan 24 '23 at 14:02
  • I use puppeteer-core but I use the connect method, also never had issues with the puppeteer browser itself. my suggestion is you should try to uninstall node. and use NVM and use node 18 or 16 instead. – Ricardo Silva Jan 24 '23 at 14:20
  • I tried using node js v18 and node js v16 but they didnt work funnily enough i tried it on my work pc and it worked using node v19 with no issues. i guess my laptops in need of a reset i guess – Quarter Pie Jan 25 '23 at 01:49

1 Answers1

0

Turns out that running the script on another machine made it work somehow. im not sure if its the different windows licences or some obscure setting I changed somewhere but this error was localized to my pc.