0

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!

Sophivorus
  • 3,008
  • 3
  • 33
  • 43
  • Small nit because of the bounty: that's not the latest node anymore. That's the current LTS version (or, near enough; at the time of this comment the latest LTS version is v14.18.1). If you install with `nvm install latest` (since your log shows you're using nvm) you will get v17.0.1 - so it might be necessary to retest everything now that Node's moved up three major versions (and all the dependencies are probably on wildly different versions now, too). – Mike 'Pomax' Kamermans Oct 23 '21 at 18:13
  • 1
    @Mike'Pomax'Kamermans Thanks! I just updated node and nvm to the latest and retested everything. Nothing changed I'm afraid, but I updated my question with this new information. – Sophivorus Oct 23 '21 at 18:24

2 Answers2

1

The library you are trying to use (pagedjs) seems to be very incomplete, based on outdated and deprecated versions of other libraries and maintained by just one developer. It has just around 100 commits in total. I would advice to switch to jsPDF. It has more then 4000 forks and I'm completely silent about commits. It's actively maintained and very popular. Nevertheless, It's just first what I found. Maybe you can find even better library...

This question might help you as well: Generate pdf from HTML in div using Javascript

Ruslan Zhomir
  • 842
  • 9
  • 27
  • This is a great idea and I may actually end up using jsPDF if I hit a wall with PagedJS, but fortunately I just got it to work thanks to the other answer and so I'll give it a chance. Thanks! – Sophivorus Oct 29 '21 at 12:39
1

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
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • Thanks a lot for your insight! I'm not sure I understand you, do you mean to say that when I run `yum install libatk-bridge-2.0.so.0` I installed the /lib version of the library but that PagedJS requires /lib64 (or vice versa)? Do you know what command I should run to install the proper library? I tried a few things but haven't seen the light yet. Thanks again!! – Sophivorus Oct 27 '21 at 15:43
  • I'd simply ask for it: `yum whatprovides */libatk-bridge-2.0.so.0` ...one cannot install a package by filename, but obviously would have to provide the package name. It's a package manager, not a file manager ... – Martin Zeitler Oct 29 '21 at 02:04
  • Thanks! That command helped me install the right package. After that a similar error occurred but your command helped me overcome it too. Then a different error occurred but I was able to sort it out. Overall, your answer and comment led me to solve the issue and so I'm giving you the bounty. Thanks again! – Sophivorus Oct 29 '21 at 12:37