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

See original GitHub issue

hi ,i’m trying to use html-pdf module , but it throws “html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath” error ,
steps i tried to resolve : 1. installed html-pdf 2. rm -rf node_modules/phantomjs-prebuilt (or npm uninstall phantomjs-prebuilt) 3. npm install phantomjs-prebuilt@2.1.13 (and phantomjs-prebuilt@2.1.4)

but no use , it was throwing same error , then i assignedoptions.phantomPath to node_modules\phantomjs-prebuilt

after that it is throwing following error , please help

{"error":{"message":"spawn EACCES","stack":"Error: spawn EACCES\\n at _errnoException (util.js:1022:11)\\n at ChildProcess.spawn (internal/child_process.js:323:11)\\n at Object.exports.spawn (child_process.js:502:9)\\n at PDF.PdfExec [as exec] (/root/PGServerJs/node_modules/html-pdf/lib/pdf.js:88:28)\\n at PDF.PdfToFile [as toFile] (/root/PGServerJs/node_modules/html-pdf/lib/pdf.js:83:8)\\n

i tried to change the permissions of phantomjs , but still it is not working

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:20

github_iconTop GitHub Comments

49reactions
Paul-JOcommented, Feb 26, 2019

In my case this solved the issue: $ (sudo) npm link phantomjs-prebuilt

I am not an expert, but it seems that since html-pdf is installed globally you have to link these global installations to your project. So my installation looks like this:

$ (sudo) npm install html-pdf -g $ (sudo) npm link html-pdf $ (sudo) npm link phantomjs-prebuilt

If this is somehow not the real way to go, I would be happy about other suggestions as I am planning to use this for an upcoming project.

10reactions
imvikaskohlicommented, May 2, 2020

Install PhantomJs

https://www.vultr.com/docs/how-to-install-phantomjs-on-ubuntu-16-04 Check phantomjs --version -> O/p 2.1.1

Then in the htm-pdf module html-pdf -> lib -> pdf.js Add the line after “this.options = options || {}” this.options.phantomPath = “/usr/local/bin/phantomjs”

Read more comments on GitHub >

github_iconTop Results From Across the Web

html-pdf: Failed to load PhantomJS module. You have to set ...
html -pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath' when using aws ec2...
Read more >
Developers - "html-pdf: Failed to load PhantomJS module ...
"html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using \'options.phantomPath · 1. installed html-pdf
Read more >
html-pdf: Failed to load PhantomJS module. You have to set ...
[Solved]-html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath' when using aws ec2-node.js.
Read more >
Html-pdf: Failed to load PhantomJS module Error
Uncaught AssertionError : html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath' At ...
Read more >
Html-pdf Node Error - General
html -pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found