galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.15k stars 169 forks source link

Node version compile issue #367

Closed visheshCuriousDev closed 5 years ago

visheshCuriousDev commented 5 years ago

This error occurs not during installation but during run time. From the error i can make out that it was compiled using node version 7 and when trying to run in node version above or below, this error occurs. I tried to even rebuild/install the package at a later version(11.9.0) but it did not solve the issue. The command i used is "sudo npm rebuild" & "npm rebuild hummus --build-from-source".

2019-04-08T06:42:19.787Z - error: Error when loading extension Error: The module '/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-pdf-password/node_modules/hummus/binding/hummus.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 51. This version of Node.js requires
NODE_MODULE_VERSION 67. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
Error: The module '/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-pdf-password/node_modules/hummus/binding/hummus.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 51. This version of Node.js requires
NODE_MODULE_VERSION 67. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:775:18)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-pdf-password/node_modules/hummus/hummus.js:5:31)
    at Module._compile (internal/modules/cjs/loader.js:734:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-pdf-password/lib/pdfPassword.js:7:14)
    at Module._compile (internal/modules/cjs/loader.js:734:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at /media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-core/lib/extensions/extensionsManager.js:122:16
    at tryCatcher (/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-core/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-core/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-core/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromiseCtx (/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-core/node_modules/bluebird/js/release/promise.js:606:10)
    at Async._drainQueue (/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-core/node_modules/bluebird/js/release/async.js:138:12)
    at Async._drainQueues (/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-core/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-core/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate (timers.js:637:19)
    at process.topLevelDomainCallback (domain.js:120:23)
galkahana commented 5 years ago

yeah, just rebuild if you switch a node version. either that or reinstall.

visheshCuriousDev commented 5 years ago

I tried them but it did not solve the issue. I tried installing in different locations. Even removed node, installed it and ran. Installation works well. But during run-time the error occurs

galkahana commented 5 years ago

I honestly don't know. but im not sure it has to do with something that i could change in hummus. especially if you say that you are doing "build from source". this would mean that hummus is built against the current nodejs version. later in runtime it finds out that the actually running node is different. so either you're changing node versions between installing and running, or that somehow you keep getting an older version. if you are sure that you are not changing versions, you could try deleting your node_modules lib in your project folder. maybe you somehow got leftovers from the past. not that i know how this is possible, but if you didn't try it...go for it. and don't use Sudo. you're not supposed to need it unless installing with -g, which you shouldn't for project resources...otherwise you could get issues like the one you keep running into (though in your case it's not the case...cause the path to the faulting .node file is obviously local to your project).

gabriel-animas commented 5 years ago

@vishesh1king Did you find a solution to this issue? I get the same error running on Azure App Services

visheshCuriousDev commented 5 years ago

@gabriel-animas I tried several ways. I ran out of time and had to stop using this. I majorly needed HummusJs because it was used in the jsreport-pdf-password package. This package was responsible for setting password to PDFs generated using JsReport.

Finally it had to be removed as it was causing random issues. I did encryption using qpdf. I believe its nothing wrong in HummusJs. Some thing wrong with that "jsreport-pdf-password" package.

As suggested by @galkahana dont use sudo to install any of node packages. Apparently i used for this package and everything went haywire.