跳转到内容

Puppeteer

针对下载依赖时,Puppeteer下载失败的解决方案

全局一次配置:让 Puppeteer 默认使用你系统里的 Chrome

一、确认本地Chrome路径

bash
ls "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"

二、写进你的 ~/.zshrc

shell
export PUPPETEER_SKIP_DOWNLOAD=true
export PUPPETEER_EXECUTABLE_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
export PUPPETEER_CACHE_DIR="$HOME/.cache/puppeteer"

使他生效:

shell
source ~/.zshrc

三、重新安装

这样就会使用本地的Chromium

shell
rm -rf node_modules package-lock.json
npm i

Will Try My Best.