简体   繁体   English

为什么我在 node js 中使用 html-to-xslx 包导出一些数据时出现 chrome 启动错误

[英]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:当我尝试使用html-to-xslx npm 包导出数据时,显示以下消息:

Error: Failed to launch chrome!错误:无法启动 Chrome! [0221/145806.785119:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. [0221/145806.785119:ERROR:zygote_host_impl_linux.cc(89)] 不支持在没有 --no-sandbox 的情况下以 root 身份运行。 See https://crbug.com/638180.TROUBLESHOOTING : https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.mdhttps://crbug.com/638180.TROUBLESHOOTINGhttps : //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']}如果我们想以 root 权限使用 chrome,我们必须在 'chrome-page-eval' 构造函数中添加 --node-sandbox: 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这种方式对我有用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试将Crystal报表导出到HTML文件时,为什么会出现“无法导出报表”错误? - Why do I get a “Failed to export the report” error when I try to export a Crystal Report to an HTML file? 尝试使用Node.js为HTML页面提供图片时收到GET错误 - I receive a GET error when trying to serve html page with image using Node.js 为什么在使用自定义 HTML 标签时在 Vue 中出现错误? - Why I get an error in Vue when using custom HTML tags? 尝试预览LESS CSS样式表时,为什么在Chrome中出现错误? - Why do I get an error in Chrome when I try to preview my LESS CSS stylesheet? 当我使用php / html导出文件时,我的会话数据会重置 - When I export files with php/html my session data resets 当我单击链接的按钮时无法获取 /to-do.html(节点 js) - Cannot GET /to-do.html when I click on button linked (Node js) 我下载了我的 chrome 书签以移动到一台新计算机,并将它保存为 XML 而不是 HTML - 当我尝试转换时出现错误 - I downloaded my chrome bookmarks to move to a new computer and it saved as a XML instead of HTML - when I try to convert i get an error 为什么在遍历 DOM 时使用节点列表或 HTML 集合中的元素时会出现未定义? - Why do I get undefined when I use elements from a node-list or HTML-Collection when traversing the DOM? 使用变量'name'时,为什么我在Chrome调试器中没有使用错误对象? - Why do I get the error object has no method in Chrome debugger when using variable 'name'? 无论如何,我可以在node.js中获取html主体 - Anyway I can get the html body in node.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM