t33n
t33n

Reputation: 343

puppeteer download firefox and chrome binaries together

I´am able to download firefox binaries for my project by set the environment variable:

npm config set PUPPETEER_PRODUCT firefox npm i puppeteer

Then inside of my project I run:

npm i puppeteer

This works fine. However when I change it back to chrome and reinstall it:

npm config set PUPPETEER_PRODUCT chrome npm i puppeteer
npm i puppeteer

It will delete the firefox binaries and only install chrome again. I tried to run npm update after switching the PUPPETEER_PRODUCT environment variable however this doesn´t work and nothing gets updated.

How can I download firefox and chrome binaries together? That I can easily switch the product value?

client = await puppeteer.launch({  product: 'firefox'  }); // or product: 'chrome'

Please notice that I can not just create a hello world project and set product: 'firefox' because the binaries does not exist and will not automatically downloaded. For any default puppeteer install only the chrome binaries will exist.

Switching to firefox won´t work until you change the environment variable PUPPETEER_PRODUCT to firefox and reinstall puppeteer and download the firefox binaries.

Upvotes: 4

Views: 3836

Answers (3)

Dimas Lanjaka
Dimas Lanjaka

Reputation: 294

to install

PUPPETEER_PRODUCT=firefox npm install puppeteer

to change product to existing puppeteer project

PUPPETEER_PRODUCT=firefox npm rebuild

available product (choose one)

PUPPETEER_PRODUCT=firefox
PUPPETEER_PRODUCT=chrome

to switch between product

const firefox = await puppeteer.launch({  product: 'firefox'  });
const chrome  = await puppeteer.launch({  product: 'chrome'  });

Upvotes: 0

bmaupin
bmaupin

Reputation: 16005

To install both Chromium and Firefox at the same time:

  1. Install Chromium

    npm install puppeteer
    
  2. Install Firefox

    cd node_modules/puppeteer
    PUPPETEER_PRODUCT=firefox node install.js
    cd ../..
    

You should now see that they're both installed:

$ ls -1d node_modules/puppeteer/.local*
node_modules/puppeteer/.local-chromium
node_modules/puppeteer/.local-firefox

Source: https://github.com/puppeteer/puppeteer/issues/5743#issuecomment-621664876

Upvotes: 1

t33n
t33n

Reputation: 343

As it seems you can only not use on windows this command via terminal:

  • PUPPETEER_PRODUCT=firefox npm install puppeteer

On linux you can run the command above and it will download the binaries. There is actually no need to use this on linux:

  • npm config set PUPPETEER_PRODUCT firefox npm i puppeteer

Upvotes: 1

Related Questions