4

I have a application that generates PDF's using html-pdf on nodejs, but after I made a deploy to the production server, I'm not able to generate. It gives this error:

'html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath'

And if I run npm install html-pdf again, it gives this error

npm ERR! errno 1
npm ERR! node@11.8.0 preinstall: `node installArchSpecificPackage`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node@11.8.0 preinstall script.

And this error replicates to other modules, but I made a turn around.

Runing node 13.7.0 and npm 6.9.0

DaCurse
  • 795
  • 8
  • 25
lufizi
  • 403
  • 2
  • 7
  • 14
  • If you can’t make this work, I’d also recommend Puppeteer to help with this purpose. It’s been my go-to for server-side HTML to PDF. – stephancasas Feb 18 '20 at 20:24
  • Are you running node 13.7 or 11.8? Your logs say something different than your text. – Joe Feb 18 '20 at 21:37
  • PhantomJS is dead, use Puppeteer, as @stephancasas suggested. Also I recommend giving a try for Gotenberg — this is Docker-powered API for converting to PDF, and I wrote small JS/TS client for it — https://github.com/yumauri/gotenberg-js-client – yumaa Feb 26 '20 at 12:09

1 Answers1

1

Can you try again with the -g flag

npm install -g html-pdf

If still not working, execute after that:

npm link html-pdf
npm link phantomjs-prebuilt

from https://github.com/marcbachmann/node-html-pdf/issues/437#issuecomment-467463285

Horatiu Jeflea
  • 7,256
  • 6
  • 38
  • 67