Mac M1本地无法启动Puppeteer问题求助
Puppeteer启动浏览器报错的解决办法
以下是针对brew安装Puppeteer后启动失败的几种实用解决方案:
指定浏览器可执行路径
brew安装的Puppeteer可能无法自动识别系统Chrome路径,手动指定即可:const browser = await puppeteer.launch({ headless: true, executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' });若使用Chrome Canary,路径替换为
/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary匹配Puppeteer与浏览器版本
版本不兼容是常见问题,要么查看当前Puppeteer对应的Chromium版本,确保系统Chrome版本接近;要么重新安装Puppeteer让它自动下载适配的Chromium:npm uninstall puppeteer npm install puppeteer --save用yarn的话替换成
yarn remove puppeteer && yarn add puppeteer更新headless模式参数
新版Chrome对headless模式做了调整,原headless: true属于旧模式,尝试切换到新版:const browser = await puppeteer.launch({ headless: "new" });修复权限问题
确保浏览器执行文件有足够权限,执行以下命令:chmod +x /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
内容的提问来源于stack exchange,提问作者Sachin Yadav
相关产品推荐
相关产品推荐

