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

执行npm install时Puppeteer出现ENOENT错误的解决求助

问题

执行npm install时遇到报错,错误信息如下:

2529 timing build:link Completed in 133ms
2530 info run puppeteer@9.1.1 install node_modules/puppeteer node install.js
2531 info run puppeteer@9.1.1 install { code: 'ENOENT', signal: undefined }
2532 timing reify:rollback:createSparse Completed in 18454ms
2533 timing reify:rollback:retireShallow Completed in 0ms
2534 timing command:install Completed in 96274ms
2535 verbose stack Error: spawn bash ENOENT
2535 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
2535 verbose stack     at onErrorNT (node:internal/child_process:478:16)
2535 verbose stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
2536 verbose pkgid puppeteer@9.1.1
2537 verbose cwd C:\d\work\bns\backend
2538 verbose Windows_NT 10.0.22000
2539 verbose node v16.17.0
2540 verbose npm  v8.19.1
2541 error code ENOENT
2542 error syscall spawn bash
2543 error path C:\d\work\bns\backend\node_modules\puppeteer
2544 error errno -4058
2545 error enoent spawn bash ENOENT
2546 error enoent This is related to npm not being able to find a file.
2546 error enoent
2547 verbose exit -4058
2548 timing npm Completed in 96388ms
2549 verbose unfinished npm timer reify 1663706237073
2550 verbose unfinished npm timer reify:build 1663706314689
2551 verbose unfinished npm timer build 1663706314695
2552 verbose unfinished npm timer build:deps 1663706314695
2553 verbose unfinished npm timer build:run:install 1663706314883
2554 verbose unfinished npm timer build:run:install:node_modules/puppeteer 1663706314884
2555 verbose code -4058
2556 error A complete log of this run can be found in:

已尝试重新克隆项目、卸载并重装Node.js与npm,问题依旧。该项目在其他设备上可正常运行,求其他解决方法。

解决方法

  • 配置Git Bash到系统环境变量:Windows下puppeteer安装依赖bash环境,将Git Bash的bash.exe路径(通常为C:\Program Files\Git\bin)添加到系统PATH变量中,添加后重启终端再执行npm install。
  • 跳过puppeteer浏览器自动下载:设置环境变量PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true,或在项目根目录创建.npmrc文件并添加puppeteer_skip_chromium_download=true,再重新执行安装。
  • 用管理员权限运行终端:右键终端选择「以管理员身份运行」,再执行npm install,规避权限不足导致的文件访问问题。
  • 清除npm缓存:执行npm cache clean --force清除缓存后,重新执行npm install。
  • 指定npm执行shell:在cmd中执行set npm_config_shell="C:\Program Files\Git\bin\bash.exe",或在PowerShell中执行$env:npm_config_shell="C:\Program Files\Git\bin\bash.exe",强制npm使用bash作为执行shell后再安装。
  • 调整puppeteer版本:修改package.json中puppeteer的版本为兼容稳定版(或与其他正常运行设备一致的版本),删除package-lock.json和node_modules后重新执行npm install。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 01:01:11