zoukankan      html  css  js  c++  java
  • prerender-spa-plugin出现Failed to launch chrome 解决方案

    在Linux (CentOS)系统下,打包带prerender-spa-plugin 这个预渲染插件的内容,出现如下报错

    Error: Failed to launch chrome!
    /mnt/workspace/xxx/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
    TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
        at onClose (/mnt/workspace/xxx/node_modules/puppeteer/lib/Launcher.js:348:14)
        at Interface.<anonymous> (/mnt/workspace/xxx/node_modules/puppeteer/lib/Launcher.js:337:50)
        at Interface.emit (events.js:327:22)
        at Interface.close (readline.js:416:8)
        at Socket.onend (readline.js:194:10)
        at Socket.emit (events.js:327:22)
        at endReadableNT (_stream_readable.js:1220:12)
        at processTicksAndRejections (internal/process/task_queues.js:84:21)
    [Prerenderer - PuppeteerRenderer] Unable to start Puppeteer
    /mnt/workspace/xxx/scripts/uat.js:14
      throw err;
     TypeError: Cannot read property 'close' of null
        at PuppeteerRenderer.destroy (/mnt/workspace/xxx/node_modules/@prerenderer/renderer-puppeteer/es6/renderer.js:140:21)
        at Prerenderer.destroy (/mnt/workspace/xxx/node_modules/@prerenderer/prerenderer/es6/index.js:87:20)
        at /mnt/workspace//node_modules/prerender-spa-plugin/es6/index.js:144:29
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
    

      

    解决方案如下:

    1、确保 prerender-spa-plugin 配置中不包含headless 和 inject配置项

    new PrerenderSPAPlugin({
                  routes: ["/future"],
                  staticDir: path.join(__dirname, '../build'),
                  renderer: new Renderer({
                    renderAfterTime: 5000
                  })
                })
    

    2、在Linux 系统下安装依赖包,命令如下:

    yum install libXScrnSaver atk java-atk-wrapper at-spi2-atk gtk3 libXt -y
    

      

  • 相关阅读:
    JS高级---沙箱小案例
    JS高级---沙箱
    JS高级---闭包案例,点赞
    JS高级---闭包案例,产生多个相同的随机数
    JS高级---闭包小案例
    JS高级---闭包
    JS高级---作用域,作用域链和预解析
    JS高级---函数作为返回值使用拓展,排序
    JS高级---函数作为参数使用
    c# 格式化字符串
  • 原文地址:https://www.cnblogs.com/ldld/p/14075059.html
Copyright © 2011-2022 走看看