How to fix M1 Mac Puppeteer chromium arm64 bug
I recently got the M1 Mac mini computer, and ran yarn
or npm
to install a project that contained Puppeteer in the package.json file, and I received this error message:
The chromium binary is not available for arm64:
If you are on Ubuntu, you can install with:
apt-get install chromium-browser
path-to-project/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:112
throw new Error();
There is a solution to this problem. The answer is to manually install chromium on your machine.
Let’s go over how to fix this problem step-by-step.
Step 1: Install chromium with Homebrew
Make sure you have Homebrew install on your M1 Mac. Once you do, open up the terminal and type the following command:
brew install chromium
If you want to check which chromium your M1 Mac is using, type the following command:
which chromium
The chromium should in the homebrew binary directory, as such:
/opt/homebrew/bin/chromium
Step 2: Allow Chromium to open on your M1 Mac
If your M1 Mac doesn’t allow third party apps to be open, you may need to give Chromium permission to do so.
Open Chromium on your machine, and you may receive an alert message as such:
Go to your System Preferences
> Security & Privacy
> General
screen, and select Open Anyway
.
Step 3: Skip future Chromium installs
The next step is tp modify your .zshrc file and add the following 2 lines of code:
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export PUPPETEER_EXECUTABLE_PATH=`which chromium`
Step 4: Restart your terminal
The final step is close your terminal, and reopen it and run your NPM or Yarn installs.
I like to tweet about code and post helpful code snippets. Follow me there if you would like some too!