当前位置:   article > 正文

puppeteer插件启动chrome失败: Error: Failed to launch the browser process!

failed to launch the browser process

转载:https://www.cnblogs.com/zhidong123/p/13345990.html

最近使用puppeteer插件启动chrome失败,有的系统无法启动唤起chrome

自己笔记本电脑安装有360会提示被阻止,允许执行即可调用成功,公司电脑,没有任何提示直接无法启动(公司杀毒软件无法配置关闭)

控制台报错:

D:\MyCode\node\09puppetter> node .\index.js       
(node:21488) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! spawn D:\MyCode\node\09puppetter\node_modules\_puppeteer@5.2.1@puppeteer\.local-chromium\win64-782078\chrome-win\chrome.exe ENOENT


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (D:\MyCode\node\09puppetter\node_modules\_puppeteer@5.2.1@puppeteer\lib\cjs\puppeteer\node\BrowserRunner.js:193:20)        
    at ChildProcess.<anonymous> (D:\MyCode\node\09puppetter\node_modules\_puppeteer@5.2.1@puppeteer\lib\cjs\puppeteer\node\BrowserRunner.js:185:85)
    at ChildProcess.emit (events.js:315:20)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
    at onErrorNT (internal/child_process.js:468:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:21488) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rePS D:\MyCode\node\09puppetter> node .\index.js       
(node:21488) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! spawn D:\MyCode\node\09puppetter\node_modules\_puppeteer@5.2.1@puppeteer\.local-chromium\win64-782078\chrome-win\chrome.exe ENOENT


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (D:\MyCode\node\09puppetter\node_modules\_puppeteer@5.2.1@puppeteer\lib\cjs\puppeteer\node\BrowserRunner.js:193:20)        
    at ChildProcess.<anonymous> (D:\MyCode\node\09puppetter\node_modules\_puppeteer@5.2.1@puppeteer\lib\cjs\puppeteer\node\BrowserRunner.js:185:85)
    at ChildProcess.emit (events.js:315:20)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
    at onErrorNT (internal/child_process.js:468:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:21488) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:21488) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28

后来经过尝试发现

强制配置chrome路径executablePath,并指定可以打开看到浏览器效果headless,可以勉强使用,如果不允许浏览器可视,我做的页面抓取内容会失败。

    let browser = await puppeteer.launch({ 
        executablePath: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', 
        headless: false })
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号