Search code examples
node.jsnpmpuppeteernpxpagedjs

Can't install PagedJS due to a Puppeteer issue


When I try to install PagedJS with the recommended npm install -g pagedjs-cli pagedjs I get:

npm WARN deprecated @babel/polyfill@7.12.1: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when neded). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 enginewhims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path /root/.nvm/versions/node/v14.17.5/lib/node_modules/pagedjs-cli/node_modules/puppeteer
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! internal/modules/cjs/loader.js:905
npm ERR!   throw err;
npm ERR!   ^
npm ERR!
npm ERR! Error: Cannot find module '/root/.nvm/versions/node/v14.17.5/lib/node_modules/pagedjs-cli/node_modules/puppeteer/install.js'
npm ERR!     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
npm ERR!     at Function.Module._load (internal/modules/cjs/loader.js:746:27)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
npm ERR!     at internal/main/run_main_module.js:17:47 {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: []
npm ERR! }

If I run npm install -g puppeteer I get the exact same error (minus the warnings).

I tried a local install with npm install pagedjs-cli pagedjs and everything went fine (when I run npm ls I get:

├── pagedjs-cli@0.1.6
├── pagedjs@0.2.0
└── puppeteer@10.4.0

which seems to indicate that the relevant packages were successfully installed locally). But when I try to run PagedJS with npx pagedjs-cli example.html -o result.pdf I get:

Loading: example.htmlError: Failed to launch the browser process!
/home/sophivorus/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome: error while loading shared libraries: libatk-bridge-2.0.so.0: cannot open shared object file: No such file or directory

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
    at onClose (/home/sophivorus/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:197:20)
    at Interface.<anonymous> (/home/sophivorus/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:187:68)
    at Interface.emit (events.js:412:35)
    at Interface.close (readline.js:530:8)
    at Socket.onend (readline.js:254:10)
    at Socket.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1334:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

I then tried installing the missing library with yum install libatk-bridge-2.0.so.0 and everything went fine (when I run ldconfig -p | grep libatk-bridge-2.0.so.0 I get:

libatk-bridge-2.0.so.0 (libc6) => /lib/libatk-bridge-2.0.so.0

which seems to indicate that the library was successfully installed). However when I retry npx pagedjs-cli example.html -o result.pdf I get the exact same error. If I avoid npx with /home/sophivorus/node_modules/.bin/pagedjs-cli example.html -o result.pdf I get the same error.

I'm on CentOS 7 and running the latest node and npm:

node -v
v17.0.1

npm -v
8.1.0

I also tried with the latest LTS version. Thanks for any help!


Solution

  • The package has another name ...

    repoquery --list at-spi2-atk.x86_64
    

    lib and lib64 are not the same thing:

    • ldd /usr/lib64/libatk-bridge-2.0.so.0.0.0
    • ldd /lib/libatk-bridge-2.0.so.0