CentOS 8 中安裝 chrome 環境

node:102799) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!

/var/www/crawler/chromium/linux-800071/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (/snapshot/crawler/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)

    at Interface.<anonymous> (/snapshot/crawler/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:183:68)

    at Interface.emit (events.js:327:22)

    at Interface.close (readline.js:424:8)

    at Socket.onend (readline.js:202:10)

    at Socket.emit (events.js:327:22)

    at endReadableNT (_stream_readable.js:1224:12)

    at processTicksAndRejections (internal/process/task_queues.js:84:21)

(Use `crawler --trace-warnings ...` to show where the warning was created)

(node:102799) 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:102799) [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.


會出現上述錯誤是原因是 chrome 執行環境不完整

請安裝以下套件

# dnf install nss.x86_64 cups-libs pango libXrandr atk at-spi2-atk libX11-xcb libXcomposite libXdamage libdrm libgbm gtk3 alsa-lib

執行完後到 chrome 目錄執行 `ldd chrome | grep not`

如果都沒有資料代表 chrome 可以正常的執行囉




參考來源:

CentOS 8 cannot locate libnss3.so (64bit)

Run Puppeteer/Chrome Headless on EC2 Amazon Linux AMI

CentOS6.5-64位安装puppeteer,提示Chrome无法启动,查找并安装缺失依赖包——吕江民·敬上


Comments

Popular posts from this blog

CentOS7 如何新增/移除 Rich Rule for firewalld

mac 安裝 mtr

如何設定 SSL VPN 分割通道 on Fortigate 80C