Apple Silicon运行bin/build-storefront.sh报错:Puppeteer无arm64 Chromium
解决Apple Silicon上Shopware Storefront构建的Puppeteer arm64兼容问题
你在Apple Silicon设备上执行bin/build-storefront.sh时遇到的Puppeteer安装报错,核心原因是旧版本Puppeteer未适配arm64架构的Chromium,以下是三个可行的解决办法:
办法1:使用Homebrew安装本地Chromium并指定给Puppeteer
- 未安装Homebrew的话先执行安装脚本:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - 安装arm64版本的Chromium:
brew install chromium - 设置环境变量让Puppeteer调用本地Chromium:
- 临时生效(当前终端会话):
export PUPPETEER_EXECUTABLE_PATH=$(which chromium) - 永久生效(添加到Shell配置文件,比如
~/.zshrc或~/.bashrc):echo 'export PUPPETEER_EXECUTABLE_PATH=$(which chromium)' >> ~/.zshrc source ~/.zshrc
- 临时生效(当前终端会话):
- 重新执行构建命令:
bin/build-storefront.sh
办法2:升级Puppeteer到支持arm64的新版本
- 进入Storefront的Node.js项目目录:
cd vendor/shopware/storefront/Resources/app/storefront - 升级Puppeteer到最新兼容版本:
npm install puppeteer@latest - 回到项目根目录重新运行构建:
cd ../../../../../../ bin/build-storefront.sh
办法3:通过Rosetta 2模拟x86_64架构运行
- 未安装Rosetta 2的话先执行安装:
softwareupdate --install-rosetta - 直接以x86模式执行构建命令:
arch -x86_64 bin/build-storefront.sh - 或者右键终端应用,选择「使用Rosetta打开」,在该终端中直接执行构建命令即可。
附报错信息
npm ERR! code 1 npm ERR! path /var/www/html/vendor/shopware/storefront/Resources/app/storefront/node_modules/puppeteer npm ERR! command failed npm ERR! command sh -c -- node install.js npm ERR! The chromium binary is not available for arm64. npm ERR! If you are on Ubuntu, you can install with: npm ERR! npm ERR! sudo apt install chromium npm ERR! npm ERR! npm ERR! sudo apt install chromium-browser npm ERR! npm ERR! /var/www/html/vendor/shopware/storefront/Resources/app/storefront/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:115 npm ERR! throw new Error(); npm ERR! ^ npm ERR! npm ERR! Error npm ERR! at /var/www/html/vendor/shopware/storefront/Resources/app/storefront/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:115:27 npm ERR! at FSReqCallback.oncomplete (node:fs:202:21) npm ERR! A complete log of this run can be found in:
内容的提问来源于stack exchange,提问作者CodeEditor712
相关产品推荐
相关产品推荐

