Home > Net >  Puppteer fails to use Firefox
Puppteer fails to use Firefox

Time:09-18

I'd like to use Firefox as a browser for my scraping app. I'm calling it like

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

...and the scraping attempt returns:

Error: Could not find expected browser (firefox) locally. Run `PUPPETEER_PRODUCT=firefox npm install` to download a supported Firefox browser binary

NB: This is not the deprecated puppeteer-firefox thing, I'm talking about the Firefox natively supported by Puppeteer.

What I've tried so far:

  • running the suggested command locally (package-lock.json was updated, package.json stayed the same)
  • removing Puppeteer folder from node_modules and running npm install to refresh it
  • made sure that Puppeteer version is 10.2.0, newest so far
  • made sure that I've got the 14th version of node (at first installer returned an error that he needs 14th node specifically)
  • npm is also the latest one

Can someone whose Firefox for Puppeteer works fine please check their package-lock.json and maybe package.json too, and share the parts of these files which are related to Puppteer? Or share thoughts how can I make it work? Where is the Firefox support declared anyway?

PS: I'm not running my app locally, I deploy it straight to Heroku and launch there.

CodePudding user response:

To resolve this I did the following:

  • Run npm config set puppeteer_product=firefox
  • Then run npm install puppeteer

Reference: https://github.com/puppeteer/puppeteer/issues/7044

CodePudding user response:

Actually the command in error is not complete. You can run this "PUPPETEER_PRODUCT=firefox npm i puppeteer"

  • Related