是否可以运行木偶师在 Ubuntu Server 16.04 上?我收到此错误。
(node:23213) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
/root/bin/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
at onClose (/root/bin/node_modules/puppeteer/lib/Launcher.js:750:14)
at Interface.<anonymous> (/root/bin/node_modules/puppeteer/lib/Launcher.js:739:50)
at Interface.emit (events.js:333:22)
at Interface.close (readline.js:414:8)
at Socket.onend (readline.js:192:10)
at Socket.emit (events.js:333:22)
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:23213) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:23213) [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.
我该如何解决此故障并让应用程序运行?
答案1
我修复了它。我必须更新我的 Linux(sudo-apt get update),然后获取库。如果不更新它,它将无法工作。
sudo apt-get install gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
之后,我必须添加'--no-sandbox',
启动代码(来自 myapp.js)。
答案2
使用最新版本的 Chromium,以下方法对我有用。请注意最近添加的依赖项。
sudo apt-get install libgtk2.0-0 libgtk-3-0 libnotify-dev
sudo apt-get install libgconf-2-4 libnss3 libxss1
sudo apt-get install libasound2 libxtst6 xauth xvfb
#recently added dependency
sudo apt-get install libgbm-dev
如果您正在使用 Docker,则可以将以下内容添加到 Docker 文件中。我也使用 Docker 进行了测试,并且有效。
RUN apt-get update && \ apt-get install -y libgtk2.0-0 libgtk-3-0 libnotify-dev \ libgconf-2-4 libnss3 libxss1 \ libasound2 libxtst6 xauth xvfb \ libgbm-dev
在调用 puppeteer 时添加了参数'--no-sandbox'
。这与 Lmao 建议的相同。如果没有这个选项,我无法让它工作。
作为参考,我使用的是 Ubuntu 20,但它应该适用于任何发行版。