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

运行Puppeteer报错:无法找到Chrome(版本118.0.5993.70)

Puppeteer在笔记本运行报错:找不到指定版本Chrome的解决办法

问题描述

我是编程新手,表述若有不当请见谅。我编写了一个使用Puppeteer的.js程序,在台式机上运行正常,但在笔记本电脑上运行时出现以下错误:

C:\Users\andre\OneDrive\Coding\Projects\Websscraper\node_modules\puppeteer-core\lib\cjs\puppeteer\node\ProductLauncher.js:298
                    throw new Error(`Could not find Chrome (ver. ${this.puppeteer.browserRevision}). This can occur if either\n` +
                          ^

Error: Could not find Chrome (ver. 118.0.5993.70). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npm install`) or
 2. your cache path is incorrectly configured (which is: C:\Users\andre\.cache\puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
    at ChromeLauncher.resolveExecutablePath (C:\Users\andre\OneDrive\Coding\Projects\Websscraper\node_modules\puppeteer-core\lib\cjs\puppeteer\node\ProductLauncher.js:298:27)
    at ChromeLauncher.executablePath (C:\Users\andre\OneDrive\Coding\Projects\Websscraper\node_modules\puppeteer-core\lib\cjs\puppeteer\node\ChromeLauncher.js:204:25)
    at ChromeLauncher.computeLaunchArguments (C:\Users\andre\OneDrive\Coding\Projects\Websscraper\node_modules\puppeteer-core\lib\cjs\puppeteer\node\ChromeLauncher.js:97:37)
    at async ChromeLauncher.launch (C:\Users\andre\OneDrive\Coding\Projects\Websscraper\node_modules\puppeteer-core\lib\cjs\puppeteer\node\ProductLauncher.js:79:28)
    at async Timeout.scrapeData [as _onTimeout] (C:\Users\andre\OneDrive\Coding\Projects\Websscraper\PuppetterAttempt2.js:51:19)

Node.js v20.7.0

我已确认Puppeteer已安装,检查了Package.Json(如下所示),且已将Chrome更新至最新版本:

{
  "name": "websscraper",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axios": "^1.6.0",
    "cheerio": "^1.0.0-rc.12",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "node-notifier": "^10.0.1",
    "nodemon": "^3.0.1",
    "open": "^9.1.0",
    "pupeteer": "^0.0.1",
    "puppeteer": "^21.4.1",
    "twilio": "^4.19.0"
  }
}

解决办法

  • 清理重复依赖:你的package.json里存在拼写错误的pupeteer和正确的puppeteer两个重复依赖,先卸载错误的依赖,再重新安装正确版本:

    npm uninstall pupeteer
    npm uninstall puppeteer && npm install puppeteer
    

    这能避免依赖冲突,确保Puppeteer安装完整。

  • 指定本地Chrome路径:如果Puppeteer仍无法找到Chrome,直接在代码中指定笔记本上Chrome的实际安装路径。Windows系统下Chrome默认路径通常为C:\Program Files\Google\Chrome\Application\chrome.exe,修改你的启动代码:

    const browser = await puppeteer.launch({
      executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
      // 保留你的其他配置项
    });
    

    注意路径中的反斜杠需要转义,也可以用正斜杠替代:'C:/Program Files/Google/Chrome/Application/chrome.exe'。

  • 重置Puppeteer缓存:删除错误提示中的缓存文件夹C:\Users\andre\.cache\puppeteer,然后重新执行npm install,让Puppeteer重新下载对应版本的Chrome,同时确保该缓存文件夹有读写权限。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 07:37:46