How to install Firefox for Puppeteer?

Viewed 3983

I've been trying to install firefox for puppeteer for a while, the docs says to run the next command:

PUPPETEER_PRODUCT=firefox npm i puppeteer

But I can't understand where to run it? I've tried

npm config set puppeteer_product firefox

Which downloads the Nightly package but then when trying to run puppeteer I get the next error:

(node:27840) UnhandledPromiseRejectionWarning: Error: Could not find browser revision 782078. Run "PUPPETEER_PRODUCT=firefox n
pm install" or "PUPPETEER_PRODUCT=firefox yarn install" to download a supported Firefox browser binary.

Can anybody help me?

1 Answers

Once you've correctly enabled Firefox for puppeteer with:

either npm

PUPPETEER_PRODUCT=firefox npm install puppeteer

or yarn:

PUPPETEER_PRODUCT=firefox yarn add puppeteer

Then you need to set the product option of puppeteer.launch to 'firefox':

const browser = await puppeteer.launch({ product: 'firefox' })
Related