CorsairOfficial / cue-sdk-node

A Node.js native wrapper around iCUE SDK
MIT License
33 stars 3 forks source link

__dirname reference to node-gyp-build prevents packaging as executable #9

Closed 24bitIO closed 4 years ago

24bitIO commented 4 years ago

In trying to package my node app as an executable using 'pkg' I receive this error when launching the .exe:

Error: No native build was found for platform=win32 arch=x64 runtime=node abi=83 uv=1 libc=glibc node=14.4.0
    loaded from: D:\snapshot\order_flash\node_modules\cue-sdk

It's described well here: https://github.com/parcel-bundler/parcel/issues/5090

The problem arises in line 1 of index.js: const binding = require('node-gyp-build')(__dirname)

To recreate: simply require the cue-sdk module, and run pkg.

24bitIO commented 4 years ago

Maybe this isn't the most correct fix, but I got around it by changing line 1 to: const binding = require('node-gyp-build')('node_modules/cue-sdk')

intrueder commented 4 years ago

This is more like an issue with pkg: https://github.com/vercel/pkg#native-addons

Native addons (.node files) use is supported, but packaging .node files inside the executable is not resolved yet. You have to deploy native addons used by your project to the same directory as the executable.

Try to copy node_modules/cue-sdk/prebuilds folder to the same folder as the executable.