有Headless_shell的木偶戏?

时间:2018-08-30 07:09:28

标签: node.js puppeteer google-chrome-headless

我正在尝试使用headless_shell处理木偶,以避免Linux中的库依赖性。当我尝试const browser = await puppeteer.launch({executablePath: 'out/Release/headless_shell'})时,浏览器已创建。但是,当我尝试使用const page = await browser.newPage();时,过程就在那里停止了,没有任何错误。     对于headless_shell的不同版本,出现此错误。

 (node:17176) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome!
    [0906/155318.398013:ERROR:icu_util.cc(172)] Invalid file descriptor to ICU data received.
    [0906/155318.398147:FATAL:content_main_delegate.cc(58)] Check failed: false. 
    #0 0x000002abf89c base::debug::StackTrace::StackTrace()
    #1 0x000002a45ca0 logging::LogMessage::~LogMessage()
    #2 0x0000029edc23 content::ContentMainDelegate::TerminateForFatalInitializationError()
    #3 0x0000029f5202 content::ContentMainRunnerImpl::Initialize()
    #4 0x000003d6b528 service_manager::Main()
    #5 0x0000029ee4a1 content::ContentMain()
    #6 0x000002ae077d headless::(anonymous namespace)::RunContentMain()
    #7 0x000002ae0808 headless::HeadlessBrowserMain()
    #8 0x000002a2e84a headless::HeadlessShellMain()
    #9 0x7f38923ac830 __libc_start_main
    #10 0x00000124f02a _start

1 个答案:

答案 0 :(得分:0)

问题是目录/文件的权限。

在安装了puppeteer时,权限是默认的nobody所有者:但并非所有文件都设置了组或其他位(即600或700)。 Puppeteer已安装为npm install -g puppeteer,并以本地用户身份运行。解决方法是对文件进行chmod设置,以将组和其他位设置为与“用户”相匹配。

cd out/Release/headless_shell #or wherever the file is
find . -type d | xargs -L1 -Ixx sudo chmod 755 xx
find . -type f -perm /u+x | xargs -L1 -Ixx sudo chmod 755 xx
find . -type f -not -perm /u+x | xargs -L1 -Ixx sudo chmod 644 xx

PS:实际错误显示为Invalid file descriptor to ICU data received,问题https://github.com/GoogleChrome/puppeteer/issues/2519对此进行了深入讨论。