当在headless:true模式下运行时,Puppeteer实际上在AWS linux服务器上工作正常,但是当我将其设置为headless:false时,错误消息为“错误:无法启动chrome!”。
我尝试使用xvfb,但是输出质量降低了。
是否可能或除了使用xvfb 在aws服务器中运行headless:false以外是否有其他选择,因为我需要GUI才能运行添加的扩展。
const pathToExtension = __dirname;
const browser = await puppeteer.launch({
headless: false,
args: [
`--enable-usermedia-screen-capturing`,
`--allow-http-screen-capture`,
`--no-sandbox`,
`--auto-select-desktop-capture-source=${source_tab}`,
`--disable-setuid-sandbox`,
`--load-extension=${pathToExtension}`,
`--disable-extensions-except=${pathToExtension}`,
`--disable-web-security`,
`--use-gl=egl`,
],
executablePath: 'google-chrome'
});
错误:
(node:980) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome!
at onClose (/var/www/html/node_modules/puppeteer-core/lib/Launcher.js:349:14)
at ChildProcess.helper.addEventListener (/var/www/html/node_modules/puppeteer-core/lib/Launcher.js:339:60)
at ChildProcess.emit (events.js:203:15)
at ChildProcess.EventEmitter.emit (domain.js:448:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
(node:980) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:980) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.