简体   繁体   中英

Why I get chrome launch error, when I export some data with html-to-xslx package in node js

When I try to export data with html-to-xslx npm package, this message displayed:

Error: Failed to launch chrome! [0221/145806.785119:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.TROUBLESHOOTING : https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

If we want to lunch chrome with root privilege, we must add --node-sandbox in 'chrome-page-eval' constructor: launchOptions: {headless: true, args:['--no-sandbox']}

Here is a full example:

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

This way worked for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM