puppeteer@5.5.0 安装:M1 上的`node install.js`

puppeteer@5.5.0 install: `node install.js` on M1

我一直在尝试处理我几个月前写的代码 运行 出现以下错误,

> puppeteer@5.5.0 install /Users/xyz/Documents/xyz.github.io/node_modules/puppeteer
> node install.js

The chromium binary is not available for arm64: 
If you are on Ubuntu, you can install with: 

 apt-get install chromium-browser

/Users/xyz/Documents/xyz.github.io/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:112
            throw new Error();

Error
    at /Users/xyz/Documents/xyz.github.io/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:112:19
    at FSReqCallback.oncomplete (node:fs:194:21)

Chromium arm64 由于某种原因被安装,puppeteer 似乎无法识别它。以上有什么解决方法吗?

我尝试过的解决方案:

https://github.com/puppeteer/puppeteer/issues/6622

已通过 50b810d 修复。全新安装节点模块

在终端中输入以下内容 sudo nano ~/.zshrc 并保存。

export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
export PUPPETEER_EXECUTABLE_PATH=`which chromium`
  1. 从项目中删除现有的节点模块、包-lock.json和缓存。

    rm -rf node_modules/
    rm -rf package-lock.json
    rm -rf .cache

  2. 安装节点模块。

    npm i

补丁有效。

----- 已更新 -------------- (27/04/2021)

确保您已经安装了 Chromium。如果你没有听从@Rocco 的建议 brew install --cask chromium.

----- 已更新 -------------- (18/11/2021)

Hajonsoft updated the thread on github - https://www.courier.com/blog/tips-and-tricks-to-setup-your-apple-m1-for-development while this maybe a good fix for most developers & dependencies/tools please note that rosetta emulation is not available in certain regions自己在东南亚验证过

------------ 已更新 -------------- (04/06/2022)

如果铬没有正确安装,请关注@Tomer Omri 建议和 运行 brew install chromium --no-quarantine.

除了上面的答案,我还需要 运行:

brew install chromium --no-quarantine

在我的 M1 上,chromium 将被正确安装