tojocky / node-printer

Native node.js printer
1.51k stars 436 forks source link

printer.js MODULE_NOT_FOUND after compiling project with pkg #307

Open SemionVino opened 3 years ago

SemionVino commented 3 years ago

I've compiled my project to an .exe file with pkg. If i run the .exe file on the same computer where i installed printer.js then everything is fine. If i run it on a different computer, then the package cannot find the printer module. Here's the error:

`pkg/prelude/bootstrap.js:1359 throw error; ^

[Function.Module._resolveFilename (internal/modules/cjs/loader.js:1027:15),Function._resolveFilename (pkg/prelude/bootstrap.js:1459:46),Function.Module._load (internal/modules/cjs/loader.js:896:27),Module.require (internal/modules/cjs/loader.js:1087:19),Module.require (pkg/prelude/bootstrap.js:1338:31),require (internal/modules/cjs/helpers.js:73:18),Object. (C:\snapshot\ckiosk\node_modules\printer\lib\printer.js:12:22),Module._compile (pkg/prelude/bootstrap.js:1433:22),Object.Module._extensions..js (internal/modules/cjs/loader.js:1218:10),Module.load (internal/modules/cjs/loader.js:1047:32)] { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\snapshot\ckiosk\node_modules\printer\lib\printer.js', 'C:\snapshot\ckiosk\controllers\receiptController.js', 'C:\snapshot\ckiosk\api\ajax.js', 'C:\snapshot\ckiosk\webApp.js', 'C:\snapshot\ckiosk\main.js' ], pkg: true }`

conquera99 commented 3 years ago

you can copy the node_printer.node from /node_modules/printer/lib/node_printer.node to your pkg output .exe