Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: The specified module could not be found

Tags:

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.

like image 938
Douglas Ludlow Avatar asked Dec 21 '16 00:12

Douglas Ludlow


People also ask

What does it mean specified module could not be found?

"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.

How do I fix the USB specified module could not be found?

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.

How do I stop RunDLL error?

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.


1 Answers

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.

like image 59
Douglas Ludlow Avatar answered Sep 19 '22 18:09

Douglas Ludlow