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

Gitpod/Replit启动Puppeteer失败:无法找到Chrome进程报错

解决Gitpod/Replit上Puppeteer启动失败问题

错误核心是代码硬编码了Windows系统的Chrome路径,而Gitpod/Replit均为Linux环境,无法找到该路径。以下是具体修复步骤:

  • 移除硬编码的浏览器路径
    检查你的Puppeteer启动代码,若存在类似executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe'的配置,直接删除该行,让Puppeteer自动调用安装时自带的Chromium。

  • 确保安装完整的Puppeteer包
    如果你使用的是puppeteer-core,切换到完整的puppeteer包:

    npm uninstall puppeteer-core
    npm install puppeteer
    

    完整包会自动下载适配当前平台的Chromium,无需手动配置路径。

  • 添加Linux环境启动参数
    Linux环境下启动Puppeteer必须禁用沙箱模式,修改启动代码:

    const puppeteer = require('puppeteer');
    
    (async () => {
      const browser = await puppeteer.launch({
        headless: 'new',
        args: [
          '--no-sandbox',
          '--disable-setuid-sandbox'
        ]
      });
      // 后续业务代码
    })();
    
  • Gitpod额外配置
    在项目根目录创建.gitpod.yml文件,添加初始化任务自动安装依赖与系统浏览器:

    tasks:
      - init: |
          npm install
          sudo apt-get update
          sudo apt-get install -y chromium-browser
    
  • Replit额外配置
    在Replit的Shell标签执行以下命令安装系统依赖:

    apt-get update && apt-get install -y chromium-browser
    

    同时确保环境变量PUPPETEER_SKIP_CHROMIUM_DOWNLOAD设置为false,让Puppeteer下载适配Replit环境的Chromium版本。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.14 20:35:19