Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
germanchiefprogrammer opened this issue Mar 7, 2022 · 8 comments
Open

Comments

@germanchiefprogrammer
Copy link

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

  • Windows 10 64bit
  • Node 14.16.1
  • pkg 5.3.2

Hope you can help me.

@themachho
Copy link

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
Copy link

paronix commented Apr 3, 2022

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
Copy link

I got the same error

@nipoonp
Copy link

nipoonp commented May 30, 2022

Try running this command

./node_modules/.bin/electron-rebuild

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

@yourawizardharry
Copy link

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

@nipoonp
Copy link

nipoonp commented Jun 8, 2022

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

@JandalZaheer
Copy link

JandalZaheer commented Jul 26, 2022

npm install @thiagoelg/[email protected] 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
Copy link

ananthdp commented Mar 2, 2023

same issue for me with nw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants