tojocky / node-printer

Native node.js printer
1.53k stars 441 forks source link

electron-builder does not copy the binary (or it does not find it!) #196

Open danielecr opened 6 years ago

danielecr commented 6 years ago

I am trying to package an app that include node printer, I compiled it natively for linux, this way

cd node_modules/printer npm install

it generates a build/Release/node_printer.node file and it works when I run in dev mode (I am using https://github.com/chentsulin/electron-react-boilerplate ) when I run as production I have:

{ Error: Cannot find module "." at /home/daniele/Development/packpickmanapp/app/main.prod.js:22:538572 at Object../node_modules/printer/lib/printer.js (/home/daniele/Development/packpickmanapp/app/main.prod.js:22:538642) at t (/home/daniele/Development/packpickmanapp/app/main.prod.js:1:270) at n (/home/daniele/Development/packpickmanapp/app/main.prod.js:1:8363) at new d (/home/daniele/Development/packpickmanapp/app/main.prod.js:1:8914) at Object../app/SswApi.js (/home/daniele/Development/packpickmanapp/app/main.prod.js:1:976) at t (/home/daniele/Development/packpickmanapp/app/main.prod.js:1:270) at Object../app/ssw-api.js (/home/daniele/Development/packpickmanapp/app/main.prod.js:1:14087) at t (/home/daniele/Development/packpickmanapp/app/main.prod.js:1:270) at Object../app/main.dev.js (/home/daniele/Development/packpickmanapp/app/main.prod.js:1:3908) code: 'MODULE_NOT_FOUND' }

when packaged I have:

{ Error: Cannot find module "." at /opt/PackPickMan/resources/app.asar/main.prod.js:22:538572 at Object../node_modules/printer/lib/printer.js (/opt/PackPickMan/resources/app.asar/main.prod.js:22:538642) at t (/opt/PackPickMan/resources/app.asar/main.prod.js:1:270) at n (/opt/PackPickMan/resources/app.asar/main.prod.js:1:8363) at new d (/opt/PackPickMan/resources/app.asar/main.prod.js:1:8914) at Object../app/SswApi.js (/opt/PackPickMan/resources/app.asar/main.prod.js:1:976) at t (/opt/PackPickMan/resources/app.asar/main.prod.js:1:270) at Object../app/ssw-api.js (/opt/PackPickMan/resources/app.asar/main.prod.js:1:14087) at t (/opt/PackPickMan/resources/app.asar/main.prod.js:1:270) at Object../app/main.dev.js (/opt/PackPickMan/resources/app.asar/main.prod.js:1:3908) code: 'MODULE_NOT_FOUND' }

and looking at asar I found:

/app.html /main.prod.js /main.prod.js.map /package.json /dist /dist/674f50d287a8c48dc19ba404d20fe713.eot /dist/912ec66d7572ff821749319396470bde.svg /dist/af7ae505a9eed503f8b8e6982036873e.woff2 /dist/b06871f281fee6b241d60582ae9369b9.ttf /dist/bundle.js /dist/bundle.js.map /dist/fee66e712a8a08eef5805a46892932ad.woff /dist/renderer.prod.js /dist/renderer.prod.js.map /dist/style.css /dist/style.css.map /dist/style.css~ /dist/printer /dist/printer/build /dist/printer/build/Release /dist/printer/build/Release/node_printer.node

the binary should be there

mizoRC commented 6 years ago

+1

danny-toi commented 6 years ago

Did you find a solution for this? @danielecr

danielecr commented 6 years ago

No, I still have problem, current workaround for my app is the option to select a folder where to put pdf of printed document. Anyway I found that moving dependencies into app/package.json (dependecies, not devDep), I have a binary that can use printer, but only on linux system. My build system is jenkins running in a docker (in a debian server), I can not recall now if in the .deb target of automatic build the printer is working, but I need a build for mac and windows with printer support.

I will try to build in one of those image provided by microsoft, when I will have time (btw, I am looking for some good [wo]man on React, and node, and RxJS, and so, to get back some time)

danny-toi commented 6 years ago

I was able to fix the problem by adding node-printer to /app/package.json, not package.json.

I'm using the two package.json structure from electron-react-boilerplate

danielecr commented 6 years ago

I was able to fix the problem by adding node-printer to /app/package.json, not package.json.

yes, it is almost what I just wrote, but this works only for the linux build, not other OS, that is what I am interested mostly

danny-toi commented 6 years ago

@danielecr The above workaround worked for MacOS 10.13.4 and Window 10. I didn't try it on Linux yet.

danielecr commented 6 years ago

ok, and then building from? I mean, I have to buy a Mac and a Windows machine or to buy some service for this? is supported some kind of cross compilation or prebuild is working?

danny-toi commented 6 years ago

I'm not sure about the cross-compilation or prebuild.

I compiled it on MacOS + XCode, and Windows + VS 2017.