"html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using \'options.phantomPath
See original GitHub issuehi ,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:
- Created 5 years ago
- Comments:20
Top Related StackOverflow Question
In my case this solved the issue:
$ (sudo) npm link phantomjs-prebuiltI 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-prebuiltIf 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.
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”