I need a node module 'html-pdf' for converting html to pdf for my electron app. Since I am using ASAR to pack my code, if i pack html-pdf in asar, i am unable to create pdf because html-pdf does some write operation within it and ASAR package is read only. Hence I need to put HTML-PDF module manually in resource folder once package is created, and then create installer. My Use Case: while auto updating the app, I need to manually copy paste the html-pdf module in any new version before creating installer. TLDR I want to install a npm module globally in users computer and I want it to be present in his pc even if my app is uninstalled.
Asked
Active
Viewed 234 times
1 Answers
0
I don't think I'd ever install a module that tried to quietly install a global module. I'd want it to either tell me to do so in the install instructions, or else manage the module internally (local install). As I understand your use case, it also doesn't sound like you really need it anyway. If the change to PDF(s) only happens as the module gets updated, then just convert HTML to PDF as part of your build process and keep the PDF files in the final package as well.

Paul
- 35,689
- 11
- 93
- 122
-
The thing is i cannot package the html-pdf module because of asar( i cannot let html-pdf inside node-modules folder of my project because that gets packaged with ASAR too). So what i am doing now is, I manually copy the module(html-pdf) to the root directory (resources) inside the generated package folder. But every time I update my app, i need to repeat the process before creating installer. I noticed that the things present in 'Roaming' directory wont get deleted on update of app. So was thinking if I could install 'html-pdf' module in users 'roaming' directory on the first install of app. – Ishwar Rimal Jun 15 '17 at 13:12
-
I'm not suggesting you do that. What I said was to run html-pdf on your build machine to convert the html files to pdfs and place them in resources prior to packaging with ASAR. You should be running some kind of automated build to do all of this (e.g. grunt, gulp, webpack, whatever) which lets you add steps without much effort. – Paul Jun 15 '17 at 14:20