my avatar
English | 日本語
All articles↩

Install Puppeteer on MacBook Pro with Apple Silicon / M1

6/10/2021

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

Install Chromium via brew:

$ brew install chromium
$ `which chromium`

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`

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’],
})

参考

This post is available at: https://dev.to/tnzk/install-puppeteer-on-macbook-pro-with-apple-silicon-m1-3kc
Kyohei Hamaguchi (tnzk) © 2010-2024