You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Puppeteer项目启动报错:需为puppeteer-core指定executablePath或channel

解决Puppeteer-extra启动时的"executablePath or channel must be specified"错误

这个错误的核心原因是:puppeteer-extra默认依赖的是puppeteer-core,而puppeteer-core是不包含Chrome浏览器二进制文件的轻量版本,启动时必须明确指定浏览器的可执行路径,或者改用自带浏览器的完整puppeteer包。

方案一:安装完整Puppeteer包(推荐)

这是最省事的方式,完整的puppeteer包会自动下载适配的Chrome浏览器,无需手动指定路径:

  1. 卸载现有冲突依赖:
npm uninstall puppeteer-core puppeteer-extra
  1. 重新安装所需包:
npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth
  1. 现有代码无需修改launch配置,重新运行即可正常启动浏览器。

方案二:手动指定Chrome可执行路径

如果你不想安装完整Puppeteer包,可以直接指向本地已安装的Chrome浏览器路径:

  • Windows系统默认路径:C:\Program Files\Google\Chrome\Application\chrome.exe
  • Mac系统默认路径:/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
  • Linux系统默认路径:/usr/bin/google-chrome

修改launch配置,添加executablePath参数:

const browser = await puppeteer.launch({
  args: ['--no-sandbox'],
  headless: false,
  ignoreHTTPSErrors: true,
  executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' // 替换为你的实际路径,Windows需转义反斜杠
})

额外注意点

你的代码中加载隐身插件的方式有误,需要调用插件函数生成实例:

// 原代码
const hidden = require('puppeteer-extra-plugin-stealth')
// 改为
const hidden = require('puppeteer-extra-plugin-stealth')()

内容的提问来源于stack exchange,提问作者Julian Zientkowski

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 23:01:12