I'm trying to use edge.js to execute some .NET code to print on windows in an Electron app. I've tried electron-edge and I've also tried manually building the edge.js modules targeting Electron following the instructions in the Electron docs, but I keep getting the following error when I try to use edge in the packaged app:
Error: The specified module could not be found. \\?\C:\path\to\app\app-1.0.0\resources\app.asar.unpacked\node_modules\edge\lib\native\win32\x64\6.5.0\edge_nativeclr.node at Error (native) at process.module.(anonymous function) (ELECTRON_ASAR.js:178:20) at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:178:20) at Object.Module._extensions..node (module.js:583:18) at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:192:18) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3) at Module.require (module.js:483:17) at require (internal/module.js:20:19)
I've checked the filesystem and the edge_nativeclr.node
module does, in fact, exist. My suspicion is that I'm somehow not building the module correctly and it's perhaps targeting the wrong version of node still and so electron is unable to import the module.
I tried several different things, including following electron-edge's steps to manually update the build.bat
and add the --target=1.4.12 --dist-url=https://atom.io/download/atom-shell
flags to the node-gyp configure build
.
I also set the following npm config options in my .npmrc
:
target=1.4.12 arch=x64 target_arch=x64 disturl=https://atom.io/download/electron runtime=electron build_from_source=true msvs_version=2015
And ran the build.bat
, making sure to set the EDGE_NATIVE
environment variable to point to the generated edge_nativeclr.node
file, but got the same result.
"The specified module could not be found" is a RunDLL error. It is related to DLL (. dll) files linked to Windows Registry and used to run tasks processed by various programs concurrently. RunDLL errors usually occur when a program is not granted access to a specific code.
Hold the Shift key on your keyboard and right click the folder that has files from your USB flash drive in it. Choose Open command window here from the menu. Command Prompt will now appear. Enter attrib -r -s -h /s /d command and press Enter to run it.
In Task Scheduler, click on Task Scheduler Library and scroll through the list in the center panel for any entry that matches the file reported by the RunDLL error message. If you find one, right-click on it and choose Disable. Once the process is disabled, you can safely close Task Scheduler.
I finally got this figured out after banging my head against the keyboard for a couple days. I got some hints from electron-userland/electron-packager#217
and electron/electron#892
, which pointed out that this error, "The specified module could not be found," could occur when the native module is missing a dependency, such as a .dll
, and that you could use Dependency Walker to check the dependencies of any given .node
module.
I loaded edge_nativeclr.node
in Dependency Walker and noticed that VCRUNTIME140.DLL
, the Visual Studio 2015 C runtime, was missing. Edge.js comes with the msvcr120.dll
, the Visual Studio 2013 C runtime, but I'd been rebuilding the module with the msvs_version
set to 2015.
Once I placed a copy of the vcruntime140.dll
in the same directory as edge_nativeclr.node
, everything started working as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With