nexe: Cannot get native modules to work with compiled app
This is a
- Bug Report
If this is a bug report, What are the steps to reproduce?
Try to build an application with nexe that requires the native module zmq (and thereafter side-load it).
Result: epic failures at runtime.
C:\git\Observer\Node\ObsNode>ObsNode.exe
nexe.js:3528
throw e
^
Error: No such native module C:\git\Observer\Node\ObsNode\build\zmq.node
at NativeModule.require (node.js:971:13)
at s (nexe.js:1:176)
at nexe.js:1:367
at bindings (nexe.js:3521:44)
at Object.__dirname.156.157.p.532.bindings (nexe.js:146691:30)
at s (nexe.js:1:316)
at nexe.js:1:367
at Object.__dirname.156.157.p.531../lib (nexe.js:146684:18)
at s (nexe.js:1:316)
at nexe.js:1:367
Notably, you can also see that the path tried above by the nexe internals was “./build/zmq.node” rather than something like “./node_modules/zmq/build/Release/zmq.node”… for some reason…?
Current config, from "package.json":
"nexe": {
"input": "app.js",
"output": "ObsNode.exe",
"temp": "tmp",
"runtime": {
"framework": "nodejs",
"version": "4.8.3",
"ignoreFlags": true
},
"browserify": {
"excludes": [
"bufferutil",
"utf-8-validate",
"memcpy"
]
}
}
Please also provide:
- Platform(OS/Version): Windows 10
- Host Node Version:
4.8.3 - Target Node Version:
4.8.3 - Nexe version:
1.1.2 - Python Version:
2.7.11
Attempted Workarounds
- Excluding it from browserify in the
"nexe.browserify.excludes"array in the"package.json"file- Build: success 👍
- Runtime: failure 👎
C:\git\Observer\Node\ObsNode>ObsNode.exe
node.js:971
throw new Error(`No such native module ${id}`);
^
Error: No such native module zmq
at NativeModule.require (node.js:971:13)
at s (nexe.js:1:176)
at nexe.js:1:367
at Object.__dirname.155.156.p.488../http-status-messages (nexe.js:135805:11)
at s (nexe.js:1:316)
at nexe.js:1:367
at Object.__dirname.155.156.p.540.../config (nexe.js:149103:21)
at s (nexe.js:1:316)
at nexe.js:1:367
at Object.__dirname.155.156.p.550.../common/constants (nexe.js:150220:11)
- Changing the
require('zmq')toglobal.require('zmq')- Build: success 👍
- Runtime: failure 👎
C:\git\Observer\Node\ObsNode>ObsNode.exe
C:\git\Observer\Node\ObsNode\node_modules\bindings\bindings.js:83
throw e
^
Error: %1 is not a valid Win32 application.
\\?\C:\git\Observer\Node\ObsNode\node_modules\zmq\build\Release\zmq.node
at Error (native)
at Object.Module._extensions..node (module.js:434:18)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at bindings (C:\git\Observer\Node\ObsNode\node_modules\bindings\bindings.js:76:44)
at Object.<anonymous> (C:\git\Observer\Node\ObsNode\node_modules\zmq\lib\index.js:6:30)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
- Changing the
require('zmq')toglobal.require('zmq')AND excluding it from browserify in the"nexe.browserify.excludes"array in the"package.json"file- Build: success 👍
- Runtime: failure 👎
C:\git\Observer\Node\ObsNode>ObsNode.exe
C:\git\Observer\Node\ObsNode\node_modules\bindings\bindings.js:83
throw e
^
Error: %1 is not a valid Win32 application.
\\?\C:\git\Observer\Node\ObsNode\node_modules\zmq\build\Release\zmq.node
at Error (native)
at Object.Module._extensions..node (module.js:434:18)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at bindings (C:\git\Observer\Node\ObsNode\node_modules\bindings\bindings.js:76:44)
at Object.<anonymous> (C:\git\Observer\Node\ObsNode\node_modules\zmq\lib\index.js:6:30)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
- Changing the
require('zmq')to a dynamic require per the README, e.g.var m = 'zmq'; if ( Math.random() > 1 ) { m = 'FAKE'; } var zmq = require(m);- Build: success 👍
- Runtime: failure 👎
C:\git\Observer\Node\ObsNode>ObsNode.exe
node.js:971
throw new Error(`No such native module ${id}`);
^
Error: No such native module zmq
at NativeModule.require (node.js:971:13)
at s (nexe.js:1:176)
at nexe.js:1:367
at Object.__dirname.155.156.p.488../http-status-messages (nexe.js:135808:11)
at s (nexe.js:1:316)
at nexe.js:1:367
at Object.__dirname.155.156.p.540.../config (nexe.js:149107:21)
at s (nexe.js:1:316)
at nexe.js:1:367
at Object.__dirname.155.156.p.550.../common/constants (nexe.js:150224:11)
- Copying the “zmq.node” addon file into the same directory as the output “ObsNode.exe”
- Build: success 👍
- Runtime: failure 👎
C:\git\Observer\Node\ObsNode>ObsNode.exe
nexe.js:3528
throw e
^
Error: No such native module C:\git\Observer\Node\ObsNode\build\zmq.node
at NativeModule.require (node.js:971:13)
at s (nexe.js:1:176)
at nexe.js:1:367
at bindings (nexe.js:3521:44)
at Object.__dirname.156.157.p.532.bindings (nexe.js:146691:30)
at s (nexe.js:1:316)
at nexe.js:1:367
at Object.__dirname.156.157.p.531../lib (nexe.js:146684:18)
at s (nexe.js:1:316)
at nexe.js:1:367
- Copying the “zmq.node” addon file into a new “build” directory with the same directory as the output “ObsNode.exe”
- Build: success 👍
- Runtime: failure 👎
C:\git\Observer\Node\ObsNode>ObsNode.exe
nexe.js:3528
throw e
^
Error: No such native module C:\git\Observer\Node\ObsNode\build\zmq.node
at NativeModule.require (node.js:971:13)
at s (nexe.js:1:176)
at nexe.js:1:367
at bindings (nexe.js:3521:44)
at Object.__dirname.156.157.p.532.bindings (nexe.js:146691:30)
at s (nexe.js:1:316)
at nexe.js:1:367
at Object.__dirname.156.157.p.531../lib (nexe.js:146684:18)
at s (nexe.js:1:316)
at nexe.js:1:367
- Copying the whole “zmq” directory into the same directory as the output “ObsNode.exe”
- Build: success 👍
- Runtime: failure 👎
C:\git\Observer\Node\ObsNode>ObsNode.exe
nexe.js:3528
throw e
^
Error: No such native module C:\git\Observer\Node\ObsNode\build\zmq.node
at NativeModule.require (node.js:971:13)
at s (nexe.js:1:176)
at nexe.js:1:367
at bindings (nexe.js:3521:44)
at Object.__dirname.156.157.p.532.bindings (nexe.js:146691:30)
at s (nexe.js:1:316)
at nexe.js:1:367
at Object.__dirname.156.157.p.531../lib (nexe.js:146684:18)
at s (nexe.js:1:316)
at nexe.js:1:367
- Naming the output file “node.exe” instead of a custom name (“ObsNode.exe”)
- Build: success 👍
- Runtime: failure 👎
C:\git\Observer\Node\ObsNode>node.exe
nexe.js:3528
throw e
^
Error: No such native module C:\git\Observer\Node\ObsNode\build\zmq.node
at NativeModule.require (node.js:971:13)
at s (nexe.js:1:176)
at nexe.js:1:367
at bindings (nexe.js:3521:44)
at Object.__dirname.156.157.p.532.bindings (nexe.js:146691:30)
at s (nexe.js:1:316)
at nexe.js:1:367
at Object.__dirname.156.157.p.531../lib (nexe.js:146684:18)
at s (nexe.js:1:316)
at nexe.js:1:367
- Downgrading to build with
nexe@0.4.2:- Build: failure 👎
- Runtime: N/A
C:\git\Observer\Node\ObsNode>nexe
----> input => 'app.js'
----> output => 'ObsNode.exe'
----> temp => 'tmp'
----> browserify => '[object Object]'
----> runtime.framework => 'nodejs'
----> runtime.version => '4.8.3'
----> runtime.ignoreFlags => 'true'
----> framework => nodejs
----> bundle app.js
path.js:8
throw new TypeError('Path must be a string. Received ' +
^
TypeError: Path must be a string. Received { http: false }
at assertPath (path.js:8:11)
at Object.win32.resolve (path.js:130:5)
at C:\git\Observer\dependencies\node.js\x64\node_modules\nexe\node_modules\resolve\lib\async.js:151:37
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
Conclusion
So, suffice to say, I’m currently at a total loss on how to supposedly get side-loaded native modules working with a nexe-compiled application.
Please help! Thanks in advance.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 23 (23 by maintainers)
@JamesMGreene Let me know if we can close this. We can add a new issue (or PR 😉 ) for the feature request
Yeah that is a logical evolution of this. like you observed its slightly more complicated with something like
zmqbecause of the external dll dependency – but perhaps that can be derived from the binding.gyp file…@JamesMGreene I think i’ll work on getting the beta released without built in bundling, and provide a suggested configuration, prior to having it baked in