thiagoelg / node-printer

Native node.js printer
132 stars 79 forks source link

Module did not self-registered (use node-printer with pkg) #45

Open germanchiefprogrammer opened 2 years ago

germanchiefprogrammer commented 2 years ago

Hi!

Thank you very much for this convenient module. It works great direct in node.

I use a console app with "pkg". When i start the console application it returns an error like this:

`

printer.exe pkg/prelude/bootstrap.js:1740 throw error; ^ Error: Module did not self-register: 'C:\Users\XXX\AppData\Local\Temp\pkg\37a8f465fa3658617f[shortend]4e1f1df5e343\@thiagoelg\node-printer\lib\node_printer.node'. at process.dlopen (pkg/prelude/bootstrap.js:2114:28) at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at Module.require (pkg/prelude/bootstrap.js:1719:31) at require (internal/modules/cjs/helpers.js:74:18) at Object. (C:\snapshot\mail-printer\node_modules\@thiagoelg\node-printer\lib\printer.js:10:22) at Module._compile (pkg/prelude/bootstrap.js:1794:22) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

`

I tested it with pkg package.json:

"assets": [  "node_modules/@thiagoelg/node-printer/**/*"   // WITH THIS LINE INCLUDED AND NOT, THE SAME ISUE   ],

I also copied the file node_printer.node directly parallel to the new exe. The same issue.

I installed the module with:

npm install @thiagoelg/node-printer

Usage in code:

const printer = require("@thiagoelg/node-printer"); console.log(printer.getPrinters());

My versions are

Hope you can help me.

themachho commented 2 years ago

Same issue using this module with an electron js app on windows. Windows 64 bit, Node v16.13.0, Electron 17.

Error: Module did not self-register: '\\?\C:\Users\uservm\Documents\lab\app\node_modules\@thiagoelg\node-printer\lib\node_printer.node'.
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1800)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1199:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1800)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\uservm\Documents\lab\app\node_modules\@thiagoelg\node-printer\lib\printer.js:10:22)
    at Module._compile (node:internal/modules/cjs/loader:1116:14)
paronix commented 2 years ago

Same here. Can easily be reproduced using Electron Fiddle using this gist: https://gist.github.com/6a6c31a914134ecae919132019e3550e

Win 10 64 bit Electron Fiddle using Electron 18.0.1

App threw an error during load Error: Module did not self-register: '\?\C:\Users\micro\AppData\Local\Temp\tmp-19104-6NpNGX2a8pUg\node_modules\@thiagoelg\node-printer\lib\node_printer.node'. at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1812) at Object.Module._extensions..node (node:internal/modules/cjs/loader:1199:18) at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1812) at Module.load (node:internal/modules/cjs/loader:988:32) at Module._load (node:internal/modules/cjs/loader:829:12) at Function.c._load (node:electron/js2c/asar_bundle:5:13343) at Module.require (node:internal/modules/cjs/loader:1012:19) at require (node:internal/modules/cjs/helpers:102:18) at Object. (C:\Users\micro\AppData\Local\Temp\tmp-19104-6NpNGX2a8pUg\node_modules\@thiagoelg\node-printer\lib\printer.js:10:22) at Module._compile (node:internal/modules/cjs/loader:1116:14)

BopItFreak commented 2 years ago

I got the same error

nipoonp commented 2 years ago

Try running this command

./node_modules/.bin/electron-rebuild

You might need electron-rebuild added as a dep in package.json

yourawizardharry commented 2 years ago

Has anyone had any luck with this? I am having the same issue with Electron 19

nipoonp commented 2 years ago

I have been having the same issue with Electron 19. When I use electron 17 it seems to be working fine.

JandalZaheer commented 2 years ago

npm install @thiagoelg/node-printer@0.5.5 rebuild --runtime=electron --target=89 --target_archive=x64

facing issue in latest version, version 0.5.5 working for me, electron 11.4.9

ananthdp commented 1 year ago

same issue for me with nw