LoginSignup
0
0

More than 1 year has passed since last update.

pupetterのerror while loading shared libraries: libnss3.so: のライブラリ依存性エラーを解決する

Posted at

pupetterのerror while loading shared libraries: libnss3.so: ... のライブラリ依存関係に関するエラー

node_modulesmd-to-pdf実行時のエラー

環境

  • CentOS8

現状

$ yarn build
yarn run v1.22.10
warning package.json: No license field
$ md-to-pdf httpdocs/resume.md --config-file ./pdf-configs/config.js
  ✖ generating PDF from httpdocs/resume.md
    → TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
ListrError: Something went wrong
    at /var/www/vhosts/self.coro-lab.com/node_modules/listr/index.js:102:18
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async main (/var/www/vhosts/self.coro-lab.com/node_modules/md-to-pdf/dist/cli.js:116:5) {
  errors: [
    Error: Failed to launch the browser process!
    /var/www/vhosts/self.coro-lab.com/node_modules/puppeteer/.local-chromium/linux-884014/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 (/var/www/vhosts/self.coro-lab.com/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:194:20)
        at Interface.<anonymous> (/var/www/vhosts/self.coro-lab.com/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:184:68)
        at Interface.emit (events.js:387:35)
        at Interface.close (readline.js:451:8)
        at Socket.onend (readline.js:224:10)
        at Socket.emit (events.js:387:35)
        at endReadableNT (internal/streams/readable.js:1317:12)
        at processTicksAndRejections (internal/process/task_queues.js:82:21)
  ],
  context: [Object: null prototype] {}
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

依存関係にあるのライブラリが見つからないようなので調べてみる。

依存関係と解決

$ ldd /var/www/vhosts/self.coro-lab.com/node_modules/puppeteer/.local-chromium/linux-884014/chrome-linux/chrome | grep "not found"
    libnss3.so => not found
    libnssutil3.so => not found
    libsmime3.so => not found
    libnspr4.so => not found
    libasound.so.2 => not found

上記の依存ライブラリが見つからない。
おそらくブラウザ関係みたいです。

下記を参考に探す。
https://rpmfind.net/linux/rpm2html/search.php?query=libnss3.so

CentOS 8-Stream向けは
nss-3.53.1-17.el8_3.x86_64.html Network Security Services CentOS 8-stream AppStream for x86_64 nss-3.53.1-17.el8_3.x86_64.rpm
のようなので

nssをインストールしてやる。

$ sudo yum install nss -y 

再度、未解決の依存関係を見ていくと、

$ ldd /var/www/vhosts/self.coro-lab.com/node_modules/puppeteer/.local-chromium/linux-884014/chrome-linux/chrome | grep not        
    libasound.so.2 => not found

libasound.so.2だけになっているので(ここ)[https://rpmfind.net/linux/rpm2html/search.php?query=libasound.so.2]で探す。

alsa-lib-1.2.5-3.el8.i686.html The Advanced Linux Sound Architecture (ALSA) library CentOS 8-stream AppStream for x86_64 alsa-lib-1.2.5-3.el8.i686.rpm
とあるので、
alsa-libをインストールすると良さそう。

$ sudo yum install alsa-lib -y

再び未解決の依存関係を見てみる。

$ ldd /var/www/vhosts/self.coro-lab.com/node_modules/puppeteer/.local-chromium/linux-884014/chrome-linux/chrome | grep "not found"
$

何も出てこないので全て解決されました。

結果

$ yarn build:pdf                                                                                                          
yarn run v1.22.10
warning package.json: No license field
$ md-to-pdf httpdocs/resume.md --config-file ./pdf-configs/config.js
  ✔ generating 

お疲れさまです!🎉

参考
- https://rpmfind.net/linux/rpm2html/search.php?query=libasound.so.2

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0