我正在尝试以 headless:false 模式启动 puppeteer。它在我的本地机器上工作,但是当我将它推送到我的服务器并尝试启动它时,我得到了这个错误:
4|scraperP | You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
4|scraperP | Error: Failed to launch chrome!
4|scraperP | [0620/073557.986542:ERROR:nacl_helper_linux.cc(310)] NaCl helper process running without a sandbox!
4|scraperP | Most likely you need to configure your SUID sandbox correctly
4|scraperP | TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
4|scraperP | at onClose (/home/pjotr/scrapermmcreation/node_modules/puppeteer/lib/Launcher.js:285:14)
4|scraperP | at Interface.helper.addEventListener (/home/pjotr/scrapermmcreation/node_modules/puppeteer/lib/Launcher.js:274:50)
4|scraperP | at Interface.emit (events.js:165:20)
4|scraperP | at Interface.close (readline.js:381:8)
4|scraperP | at Socket.onend (readline.js:154:10)
4|scraperP | at Socket.emit (events.js:165:20)
4|scraperP | at endReadableNT (_stream_readable.js:1101:12)
4|scraperP | at process._tickCallback (internal/process/next_tick.js:152:19)
当我以 headless:true 模式启动时,我没有收到 htis 错误。知道如何解决这个问题吗?这就是我启动 puppeteer 的方式:
var browser = await puppeteer.launch({
args: [
'--ignore-certificate-errors',
'--no-sandbox',
'--disable-setuid-sandbox',
'--window-size=1920,1080',
"--disable-accelerated-2d-canvas",
"--disable-gpu"],
ignoreHTTPSErrors: true,
headless: false,
});
最佳答案
您可以尝试欺骗 headless chrome 在启用 GPU 的情况下运行:
const browser = await puppeteer.launch({
headless: false,
args: ['--headless'],
})
关于node.js - Puppeteer 没有在 headless :false mode 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50942859/