DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

kyohei
kyohei

Posted on

Install Puppeteer on MacBook Pro with Apple Silicon / M1

For those who wouldn't like to work outside the CLI.

Install Chromium via brew:

$ brew install chromium
$ `which chromium`
Enter fullscreen mode Exit fullscreen mode

Set an environemntal variable to prevent [npm/yarn/pnpm] install downloading Chromium automatically (I'd put .env into the repo so coworkers with Apple Silicon can $ source .env .)

export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export PUPPETEER_EXECUTABLE_PATH=`which chromium`
Enter fullscreen mode Exit fullscreen mode

Although in some situations you need to patch Puppeteer since it has a hard-coded executable path to /usr/bin/chromium-browser, you can try an option of puppeteer.launch to overwrite it.

const browser = await puppeteer.launch({
    executablePath: process.env[โ€˜PUPPETEER_EXECUTABLE_PATHโ€™],
})
Enter fullscreen mode Exit fullscreen mode

References

Top comments (1)

Collapse
 
oitan profile image
Alikhan Oitan • Edited on

Thank you! Your post helped me with the problem I had.
brew install --cask chromium --no-quarantine is better to not have issues opening chromium and actually use it. Also some people might need PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM=true on their env file and during puppeteer installation.

The Complete Guide to Full Stack Web3 Development

>> Check out this classic DEV post <<