Closed gentios closed 5 years ago
@gentios This looks like it should be a fairly easy update to allow for your use case. The places which require the 'fs' / 'path' module are thankfully not a part of the actually library, I will do some test cases to see if removing the "bindings" module can be made optional for installation. How are you installing nopodofo? Thank you for reporting this issue.
@corymickelson thank you for the support
I am in a MacOS environment and I have installed Podofo 0.9.6 using Brew
I am also installing nopodofo through npm like: npm install nopodofo
@gentios I'm still probably a couple weeks out from publishing a new version, in which I will add a direct require() statement to the compiled binding binary thus removing the "bindings" module which is referencing the 'fs' module. If you can't wait that long you may begin developing immediately by updating line 1 in index.js from
exports.nopodofo = require('bindings')('nopodofo')
// to
exports.nopodofo = require('./build/Release/nopodofo.node')
and removing 'bindings' and 'file-uri-to-path' from node_modules. The use of the bindings library is only for easily swapping back and forth between release and debug builds of nopodofo.
@corymickelson thank you for the great support.
I have done the steps but I am having a problem same as #77
dlopen(/demo-nopodofo/universal-starter/node_modules/nopodofo/build/Release/nopodofo.node, 1): no suitable image found
Steps I tried:
npm i nopodofo
nopodofo index.js
regarding the changes aboveAm I missing any steps from the documentation
Ps: I will also update this thread later on with the steps that I took to set it up in Angular
Thank you
Aha, probably this is because I am using nopodofo:0.8.0 and the CmakeLists.txt is looking for Podofo to be installed in /usr/local/ and currently my podofo bin is in /opt/local/bin/
@gentios Thanks, I've pushed some changes to master. Im not a regular mac user, but I have built and run some simple programs on mac with the latest master. You can build release or debug version with npm run build or npm run build:debug. If you could try to build as stated above and then just run the Document.js file with node --expose-gc ./node_modules/.bin/alsatian ./spec/unit/Document.js
and let me know if that works for you that would be appreciated. Thanks.
@corymickelson thank you for the fast response, I really appreciate it.
I tried and the build is failing due to
make[2]: *** No rule to make target `/usr/local/lib/libpodofo.dylib', needed by `Debug/nopodofo.node'. Stop. make[1]: *** [src/CMakeFiles/nopodofo.dir/all] Error 2 make: *** [all] Error 2 ERR! OMG Process terminated: 2 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! nopodofo@1.0.0-pre build:debug: `cmake-js build -D -s=c++17` npm ERR! Exit status 1
However I have that /usr/local/lib/libpodofo.dylib
in my directory
Update: I think I didn't had a clean env so I cleaned it up and the build passed
However when I run the command above I get the following error:
node --expose-gc node_modules/.bin/alsatian spec/unit/Document.js
ERROR LOADING FILE: /Users/gentios/Documents/NoPoDoFo/spec/unit/Document.js
Error: Unable to find nopodofo binding binary
at Object.<anonymous> (/Users/gentios/Documents/NoPoDoFo/index.js:8:15)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/gentios/Documents/NoPoDoFo/spec/unit/Document.js:10:13)
at Module._compile (module.js:652:30)```
I can confirm that the binary file exists in ```/build/Release/nopodofo.node```
@gentios ok, so we probably have an error that is being hidden by the update i've pushed removing the 'bindings' module. To get the actual error, which im guessing is some type of module initialization error, from the terminal in the root of your project directory, run node
and from the node prompt run require({path to nopodofo.node})
if there is an error you will get it here, if not you should get a somewhat large object printed to the terminal. Please reply with whatever is returned from the require
statement, and thanks for working through these errors, they are extremely helpful in getting this module working on all platforms
Thank you too for the support @corymickelson
Here is the output
Error: dlopen(/Users/gentios/Documents/NoPoDoFo/build/Release/nopodofo.node, 1): Symbol not found: _jpeg_resync_to_restart
Referenced from: /Users/gentios/Documents/NoPoDoFo/build/Release/nopodofo.node
Expected in: flat namespace
in /Users/gentios/Documents/NoPoDoFo/build/Release/nopodofo.node
at Object.Module._extensions..node (module.js:681:18)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)```
@gentios Thanks, from what you've shared above, this looks like we are trying to import symbols from one compiler to another, example. maybe podofo was built with gcc and nopodofo with clang, or possibly podofo was built against a different c++ standard than nopodofo, it also maybe that when nopodofo is required it is linking to a different podofo build than the one it was compiled against. You can try removing additional libpodofo.dylib that exists on the lookup path (/usr/local , /usr, and /opt/local), rebuild and retry from the terminal. I will see if I can provide a better solution going forward, maybe include podofo and it's dependencies in the repo and build podofo as a submodule of nopodofo.
@gentios I just tried using the homebrew podofo. I first removed all other instances of podofo from my /usr/local and /opt/local directories. Installed the homebrew podofo package to it's default location /usr/local/Cellar/podofo/0.9.6 and updated the PODOFO_LIBRARY and PODOFO_INCLUDE_DIR paths to include this location, did a ./node_modules/.bin/cmake-js clean && ./node_modules/.bin/cmake-js build -s=c++17 -D
(this can also be achieved with npm run clean and npm run build:debug), and so far this looks to be a valid build. It is missing libidn, and libtiff which limits some of the capabilities of podofo/nopodofo, but it is working. I added the homebrew paths to latest master if you want to try the above. If you are still finding yourself stuck, I can try and hop on a google chat /screen share with you to go over what i have and we can see where you have diverged.
@corymickelson thank you for the great support.
Update: I finally made it happen with the info that you provided.
I would be happy to open a PR and update the docs regarding the Mac Environment
@corymickelson thank you for your best support
First, thank you for the module, it looks very promising and I hope that it will do the job in my project. However I have a different approach on how to use the module, and I need to use it in Angular or Angular Universal
I understand that the module is made for NodeJs, but I was wondering if we can support also Angular Universal which is Angular run and compiled in the serverside.
The only issue that I am facing is that, Angular cannot identify native node modules such as: fs, path which are used in the nopodofo module it self.