2019-12-06T16:09:57.053282+00:00 app[web.1]: Error: Failed to launch chrome!
2019-12-06T16:09:57.053298+00:00 app[web.1]:
2019-12-06T16:09:57.053301+00:00 app[web.1]: (chrome:44): Gtk-WARNING **: 16:09:57.031: cannot open display:
2019-12-06T16:09:57.053303+00:00 app[web.1]:
2019-12-06T16:09:57.053305+00:00 app[web.1]:
2019-12-06T16:09:57.053308+00:00 app[web.1]: TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
2019-12-06T16:09:57.053310+00:00 app[web.1]:
2019-12-06T16:09:57.053312+00:00 app[web.1]: at onClose (/app/node_modules/puppeteer/lib/Launcher.js:348:14)
2019-12-06T16:09:57.053314+00:00 app[web.1]: at ChildProcess. (/app/node_modules/puppeteer/lib/Launcher.js:338:60)
2019-12-06T16:09:57.053317+00:00 app[web.1]: at ChildProcess.emit (events.js:215:7)
2019-12-06T16:09:57.053319+00:00 app[web.1]: at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
2019-12-06T16:10:26.921203+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/product/new?search=https%3A%2F%2Fwww.walmart.com%2Fip%2FHamilton-Beach-Set-n-Forget-6-Quart-Slow-Cooker-Model-33969%2F16913518" host=arcane-wave-04024.herokuapp.com request_id=34a979c5-a553-4ba2-b233-af91b577d74a fwd="124.29.252.211" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
我收到这个错误。我已经设置了以下内容: puppeteer.launch({ args: ['--no-sandbox'] });
已添加:https://github.com/jontewks/puppeteer-heroku-buildpack 构建包。
任何人都可以帮我解决这个问题吗?代码在本地主机上运行良好。但是当我将它部署到heroku上时,它不断地给出这个错误。
最佳答案
我在使用 puppeteer 和 Heroku 时遇到了同样的问题。我安装了您提到的相同构建包,并使用了以下代码,现在它工作正常。
puppeteer.launch({headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox']})
P.S:我在安装构建包后再次部署。
关于node.js - Heroku 上出现错误。无法启动 Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59216918/