[英]Failed to launch chrome using puppeteer in Centos 7
在发布此问题之前,我已经阅读了 stackoverflow、github 和博客中的每个线程。
我正在尝试在 Centos 7 中运行puppeteer
这是我的简单程序
const browser = await puppeteer.launch({
headless:true,
args: ["--no-sandbox", "--disable-setuid-sandbox"]
})
const page = await browser.newPage()
await page.setViewport({ width: 1280, height: 800 })
await page.goto('https://www.nytimes.com/')
await page.screenshot({ path: 'nytimes.png', fullPage: true })
await browser.close()
Error: Failed to launch chrome!
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
at onClose (/home/admin/web/xxxx/puppet_test/node_modules/puppeteer/lib/Launcher.js:348:14)
at Interface.<anonymous> (/home/admin/web/xxxx/puppet_test/node_modules/puppeteer/lib/Launcher.js:337:50)
at Interface.emit (events.js:326:22)
at Interface.close (readline.js:416:8)
at Socket.onend (readline.js:194:10)
at Socket.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
我已经安装了谷歌博客和Puppeteer 文档中所需和建议的所有依赖项
我什至尝试另外安装 google-chrome 并为 puppeteer 提供其路径executablePath: '/usr/bin/google-chrome'
但它没有帮助。 ldd chrome | grep not
ldd chrome | grep not
也没有用。
Puppeteer 在我的其他 Centos7 安装中运行良好,但不明白为什么它在这里不起作用。 请帮忙!
Node v12.20.1
Puppeteer v2.0.0
您安装的那些依赖项与 Chromium 相关,而不是 Chrome。 然后你提到/usr/bin/google-chrome
,所以也许你使用的是 google Chrome 而不是 Chromium。 它们不是相同的产品。
尝试安装并运行 Chromium:
# yum install chromium
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.