tpisto / pdf-fill-form

Fill PDF forms and return either filled PDF or PDF created from rendered page images.
MIT License
227 stars 48 forks source link

Error: Cannot find module '/lib/../build/Release/pdf_fill_form' #62

Closed 80sPop closed 4 years ago

80sPop commented 5 years ago

Hi, The script runs fine in command mode: $ node show.js

But when I bundle modules with $ browserify show.js > show-b.js

And then insert into html: <!doctype html>

show.php

I get the following errors in console:

Error: Cannot find module '/lib/../build/Release/pdf_fill_form' at o (show-b.js:1) at show-b.js:1 at show-b.js:47 at Object. (show-b.js:53) at Object.2 (show-b.js:54) at o (show-b.js:1) at show-b.js:1 at Object.3../lib/pdf-fill-form.js (show-b.js:56) at o (show-b.js:1) at r (show-b.js:1) show-b.js:1 Uncaught Error: Cannot find module '/lib/../build/default/pdf_fill_form' at o (show-b.js:1) at show-b.js:1 at show-b.js:51 at Object. (show-b.js:53) at Object.2 (show-b.js:54) at o (show-b.js:1) at show-b.js:1 at Object.3../lib/pdf-fill-form.js (show-b.js:56) at o (show-b.js:1) at r (show-b.js:1)

OS: Ubuntu 18.04.1 LTS Node.js v8.12.0

Any help here is much appreciated.

pastorryanhayden commented 5 years ago

I'm running into the same error, did you find a way to fix this? It's rendering pdf-fill-form unusable for me.

80sPop commented 5 years ago

I couldn't get it to work with Browserify, but I was able to fill my form using PDF Tool Kit. You can find the tutorial here: https://www.sitepoint.com/filling-pdf-forms-pdftk-php/

senica commented 5 years ago

Anyone find a solution for this? Are you guys using OSX? I have an older install that works, but going through the release log, I don't see anything that suggests the build directory existed previously. I must have built it manually.

Let me know if anyone has a solution or what build they are referring to.

senica commented 5 years ago

You can extract the attached file into ./node_modules/pdf-fill-form/build

Try that and see if that works for you. It was build on Ubuntu, so may need to be rebuilt for your platform.

build.tar.gz

sc85 commented 5 years ago

I get a similar error when building on Debian Jessie with Node 10. ERROR in ./node_modules/pdf-fill-form/lib/pdf-fill-form.js Module not found: Error: Can't resolve '/app/node_modules/pdf-fill-form/lib/../build/Release/pdf_fill_form' in '/app/node_modules/pdf-fill-form/lib'. I just don't understand why this is happening since there is a pdf-fill-form.node file in the build/Release folder and a sub folder called ob.target. All in all in looks quite similar as the attached file by @senica.

Any ideas what might go wrong?

sc85 commented 5 years ago

A little update form my side: My issue appeared while I was using webpack. The first step was to the solution was to add node-loader and updating webpack configuration, but this still did not work. I then noticed that one of the three former errors disappeared (one for each build version Debug, Release and default). As far as I can tell webpack cannot handle the nested try-catch block in lib/pdf-fill-form.js of this package, since it tries to require all 3 listed versions but can only find one of them. My solution for now is to simply ignore webpack and directly run my code, because then the try-catch block works as intended.

MirandaDora commented 5 years ago

same error here, any updates?

olivierto commented 5 years ago

same error with Webpack, it seems that it can't resolve "dynamic" require

olivierto commented 5 years ago

My solution for now is to simply ignore webpack and directly run my code, because then the try-catch block works as intended.

@sc85 what do you mean by this?

sc85 commented 5 years ago

@olivierto I tried first to run my code through webpack, add the generated file to a docker container and run it the file as soon as the container spins up. As already known this doesn't work. I now simply deploy all my code to the docker container (multiple files), install all dependencies and run my start script. That's it and it works as expected. I have no clue why webpack has some issues with these multiple require calls within try-catch which basically check if a certain file is available or not.

olivierto commented 5 years ago

@sc85 thanks for your feedback. In fact, webpack is changing default require by a _webpackrequire which prevents "dynamic" require from working and so the pdf-fill-form. I've found a solution to this in this stackoverflow answer