【问题标题】:Why I get chrome launch error, when I export some data with html-to-xslx package in node js当我在节点 js 中使用 html-to-xlsx 包导出一些数据时,为什么会出现 chrome 启动错误
【发布时间】:2019-12-13 22:43:19
【问题描述】:

当我尝试使用html-to-xslx npm 包导出数据时,显示此消息:

错误:无法启动 chrome! [0221/145806.785119:ERROR:zygote_host_impl_linux.cc(89)] 运行为 不支持不带 --no-sandbox 的 root。看 https://crbug.com/638180.TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

【问题讨论】:

    标签: html node.js xlsx


    【解决方案1】:

    如果我们想以 root 权限使用 chrome,我们必须在 'chrome-page-eval' 构造函数中添加 --node-sandbox:launchOptions: {headless: true, args:['--no-sandbox']}

    这是一个完整的例子:

        const conversionFactory = require('html-to-xlsx');
        const chromeEval = require('chrome-page-eval')({ puppeteer, launchOptions: {headless: true, args:['--no-sandbox']} });
        const conversion = conversionFactory({
          extract: chromeEval
        })
    

    这种方法对我有用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-12
      • 1970-01-01
      • 2021-09-10
      • 2017-12-12
      • 2020-11-19
      • 2016-09-11
      • 2018-12-07
      • 2022-01-19
      相关资源
      最近更新 更多