错误:指定的模块找不到
我试图使用edge.js来执行一些.NET代码,以在电子应用程序的窗口上打印。 我已经试过电子边缘 ,我也尝试手动build立edge.js模块针对Electron按照电子文档中的说明 ,但是当我尝试在封装的应用程序中使用边缘时,我不断收到以下错误:
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)
我已经检查了文件系统,并且edge_nativeclr.node
模块确实存在。 我的怀疑是,我不知道如何不正确地build立模块,它可能是针对错误版本的节点,所以电子无法导入模块。
我尝试了几个不同的东西,包括遵循electron-edge的手动更新build.bat
的步骤 ,并将--target=1.4.12 --dist-url=https://atom.io/download/atom-shell
标志添加到node-gyp configure build
。
我也在我的.npmrc
设置了下面的npmconfiguration选项:
target=1.4.12 arch=x64 target_arch=x64 disturl=https://atom.io/download/electron runtime=electron build_from_source=true msvs_version=2015
并运行build.bat
,确保将EDGE_NATIVE
环境variables设置为指向生成的edge_nativeclr.node
文件,但得到相同的结果。
我把头撞在键盘上好几天后终于明白了。 我从electron-userland/electron-packager#217
和electron/electron#892
得到了一些提示,指出当本地模块缺less依赖性时,可能会发生这个错误,“指定的模块找不到”作为一个.dll
,你可以使用Dependency Walker来检查任何给定.node
模块的依赖关系。
我在Dependency Walker中加载了edge_nativeclr.node
,注意到Visual Studio 2015 C运行时VCRUNTIME140.DLL
丢失了。 Edge.js带有msvcr120.dll
,Visual Studio 2013 C运行库,但是我一直在用msvs_version
设置为2015重build模块。
将vcruntime140.dll
的副本放在与vcruntime140.dll
相同的目录中edge_nativeclr.node
,所有内容都按预期工作。
即使我已经正确安装了VC ++ Redistributable x64,我也遇到了这个错误。 事实certificate,在我的情况下,错误实际上并不是一个问题,因为一切正常(我能够运行与电子边缘电子快速启动应用程序)。
即便如此,作者已经修复了安装,以避免错误发生。 https://github.com/kexplo/electron-edge/issues/25#issuecomment-272908409
另外请注意,如果您在Dependency Walker中加载了edge_nativeclr.node,您将看到正确parsing的VCRUNTIME140.DLL(例如,在我的PC上的C:\ Windows \ System32下)。 但是,您可能会看到几个问号和错误。 事实certificate,这只是由于Dependency Walker的一些限制,而不是一个实际的问题。 请参阅依赖项Walker:缺lessdll