pofider / phantom-html-to-pdf

Highly scalable html to pdf conversion using phantom workers
MIT License
159 stars 33 forks source link

Module not found: Error: Can't resolve 'fs' in "to/file/path" in React project #80

Closed webdeveloper0429 closed 7 years ago

webdeveloper0429 commented 7 years ago

Module not found: Error: Can't resolve 'fs' Module not found: Error: Can't resolve 'child_process' Module not found: Error: Can't resolve 'cluster' Module not found: Error: Can't resolve 'net' Module not found: Error: Can't resolve 'dns'

when I run project, these error shows. my project is React. I have no idea how to use this package...

bjrmatos commented 7 years ago

hi! this package is designed to run in a node.js environment, not in the browser, i assume that you are trying to use it in the browser since you are mentioning React

bjrmatos commented 7 years ago

what i mean is that you can't import this package in a React component, because phantom-html-to-pdf is designed to import modules that are only present in node.js.

webdeveloper0429 commented 7 years ago

Thanks. then how can I use this in my project? I like this package since this has pagenum

bjrmatos commented 7 years ago

then how can I use this in my project?

well you will have to use this package from a node.js backend/server and make a special http route (let's call it pdf route) that it is designed to receive http request and render pdf using this package, then from your React front-end you will need to call the pdf route (using AJAX), then handle the response and show it in the browser.

i will close the issue since this is not a problem, i will recommend you to try to look for some help in stackoverflow, there you will probably find people that are willing to help you in more questions that you will probably have.

webdeveloper0429 commented 7 years ago

Thank you.