marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.56k stars 545 forks source link

html-pdf lib error #639

Open hariaravind10 opened 3 years ago

hariaravind10 commented 3 years ago

AssertionError [ERR_ASSERTION]: html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath' at new PDF (path of my folder/node_modules/html-pdf/lib/pdf.js:40:3) at Object.createPdf [as create] (/path of my folder/node_modules/html-pdf/lib/index.js:10:14)

BriniM commented 3 years ago

I have recently initialized and installed html-pdf, it appears that the new path to the PhantomJS Binary is in node_modules/phantomjs-prebuilt/bin/phantomjs instead of node_modules/phantomjs/bin/phantomjs.

hariaravind10 commented 3 years ago

How to solve the issue.. Please send the steps to solve this.

I am getting html-pdf in local but i didn't get it on AWS ec2 RHEL server.

Please help me

nishvs commented 3 years ago

You need to install the phantam js prebuilt manuallyto the node_modules directory in the project. Remove the existing phantomjs-prebuilt and the install the library manually.

I did it by adding the following lines in my dockerfile

RUN cd node_modules/ \ && rm -r phantomjs-prebuilt \ && wget -qO- "https://github.com/dustinblackman/phantomized/releases/download/2.1.1a/dockerized-phantomjs.tar.gz" | tar xz -C / \ && npm config set user 0 \ && npm install phantomjs-prebuilt

Add this line as the last step in docker file before the CMD line

hariaravind10 commented 3 years ago

You need to install the phantam js prebuilt manuallyto the node_modules directory in the project. Remove the existing phantomjs-prebuilt and the install the library manually.

I did it by adding the following lines in my dockerfile

RUN cd node_modules/ && rm -r phantomjs-prebuilt && wget -qO- "https://github.com/dustinblackman/phantomized/releases/download/2.1.1a/dockerized-phantomjs.tar.gz" | tar xz -C / && npm config set user 0 && npm install phantomjs-prebuilt

Add this line as the last step in docker file before the CMD line

I am not able to install the phantomjs-prebuilt plese help me I am not using the docker, I am using ec2 instance and directly run the node using pm2.

atrvicky commented 1 year ago

8