admin管理员组

文章数量:814956

Puppeteer无法在Windows 10上连接到Chromium

告诉我们您的环境:

木偶版本:1.11.0平台/操作系统版本:Windows 10 1709网址(如果有):Node.js版本:10.x.x和11.4.0什么步骤可以重现问题?

const puppeteer = require(“ puppeteer”);puppeteer.launch();预期的结果是什么?无头浏览器在后台启动,没有控制台错误。

相反会发生什么?chrome.exe在没有任何命令行开关的情况下运行,打开了一个无头窗口,最终该选项卡也崩溃了,直到被Puppeteer杀死。

(node:27296) UnhandledPromiseRejectionWarning: TimeoutError: Timed out after 30000 ms while trying to connect to Chrome! The only Chrome revision guaranteed to work is r609904
    at Timeout.onTimeout (C:\Projects\foo\node_modules\puppeteer\lib\Launcher.js:353:14)
    at listOnTimeout (timers.js:324:15)
    at processTimers (timers.js:268:5)
(node:27296) 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(). (rejection id: 1)
(node:27296) [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.

我在启动Chromium进程之前在Launcher.js中添加了console.log(chromeArguments)-

[ '--disable-background-networking',
  '--disable-background-timer-throttling',
  '--disable-backgrounding-occluded-windows',
  '--disable-breakpad',
  '--disable-client-side-phishing-detection',
  '--disable-default-apps',
  '--disable-dev-shm-usage',
  '--disable-extensions',
  '--disable-features=site-per-process',
  '--disable-hang-monitor',
  '--disable-ipc-flooding-protection',
  '--disable-popup-blocking',
  '--disable-prompt-on-repost',
  '--disable-renderer-backgrounding',
  '--disable-sync',
  '--disable-translate',
  '--metrics-recording-only',
  '--no-first-run',
  '--safebrowsing-disable-auto-update',
  '--enable-automation',
  '--password-store=basic',
  '--use-mock-keychain',
  '--headless',
  '--hide-scrollbars',
  '--mute-audio',
  '--disable-gpu',
  'about:blank',
  '--remote-debugging-port=0',
  '--user-data-

dir = C:\ Users \ foobaz \ AppData \ Local \ Temp \ puppeteer_dev_profile-tW27Rg']使Node.js忽略了参数。没有现有的(Chromium的)chrome.exe有效,只有Chrome的chrome.exe。

回答如下:

我在github问题上发现了这个。

-disable-extensions在我的公司环境中是禁止的。

那是愚蠢的(它强制执行的扩展对安全性不敏感,也不保护或强制执行任何操作。]

puppeteer.launch({ignoreDefaultArgs:['--disable-extensions']})对其进行了修复

本文标签: Puppeteer无法在Windows 10上连接到Chromium