我有一个node12应用程序,它在gcloud应用程序引擎上运行了数周。现在,它在尝试启动傀儡师时突然崩溃:
/workspace/node_modules/puppeteer/.local-chromium/linux-737027/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory
2020-05-13 14:42:35 default[20200513t163546]
2020-05-13 14:42:35 default[20200513t163546]
2020-05-13 14:42:35 default[20200513t163546] TROUBLESHOOTING:
https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
2020-05-13 14:42:35 default[20200513t163546]
2020-05-13 14:42:35 default[20200513t163546] at onClose
(/workspace/node_modules/puppeteer/lib/Launcher.js:547:20)
2020-05-13 14:42:35 default[20200513t163546] at Interface.<anonymous>
(/workspace/node_modules/puppeteer/lib/Launcher.js:537:65)
2020-05-13 14:42:35 default[20200513t163546] at Interface.emit (events.js:322:22)
2020-05-13 14:42:35 default[20200513t163546] at Interface.close (readline.js:409:8)
2020-05-13 14:42:35 default[20200513t163546] at Socket.onend (readline.js:187:10)
2020-05-13 14:42:35 default[20200513t163546] at Socket.emit (events.js:322:22)
2020-05-13 14:42:35 default[20200513t163546] at endReadableNT (_stream_readable.js:1187:12)
2020-05-13 14:42:35 default[20200513t163546] at processTicksAndRejections
(internal/process/task_queues.js:84:21)
这是我的源代码:
const browser = await puppeteer.launch({
timeout: 10000,
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
我的应用程序:
runtime: nodejs12
instance_class: F4_1G
我的包.json
{
...
{
"dependencies": {
"@google-cloud/firestore": "^3.7.5",
"@google-cloud/storage": "^4.7.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"fs": "0.0.1-security",
"path": "^0.12.7",
"puppeteer": "^3.0.4",
"resemblejs": "^3.2.4",
"stream": "0.0.2"
},
"engines": {
"node": "12.x.x"
}
}
我在Firebase(node10(,Heroku(node12(和一些本地托管合作伙伴等其他环境中遇到了同样的问题。主要问题似乎是,缺少一些傀儡师为了启动Chrome而需要的模块。然而,它已经在Google App Engine上工作了数周,作为唯一的环境 - 现在,它不再工作了。
我遇到了同样的问题,我使用以下方法解决了它:
-NodeJS 10 和 Puppeteer 版本 2.1.1。 - 使用以下参数初始化浏览器:
const browser = await puppeteer.launch ({ args: ['--no-sandbox' ] }(;
似乎在运行时中仍然没有添加该库。