[英]Error: The specified module could not be found
我正在尝试使用edge.js来执行一些.NET代码,以便在Electron应用程序的Windows上打印。 我已经尝试了电子边缘 ,我也尝试按照Electron文档中的说明手动构建针对Electron的edge.js模块,但是当我尝试在打包的应用程序中使用edge时,我不断收到以下错误:
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.bat
并添加--target=1.4.12 --dist-url=https://atom.io/download/atom-shell
flags node-gyp configure build
。
我还在.npmrc
设置了以下npm配置选项:
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
环境变量设置为指向生成的edge_nativeclr.node
文件,但得到相同的结果。
我终于在把头撞到键盘上几天之后弄明白了。 我从electron-userland/electron-packager#217
和electron/electron#892
得到了一些提示,它指出当本机模块缺少依赖关系时,可能会发生此错误“无法找到指定的模块”,例如作为.dll
,您可以使用Dependency Walker来检查任何给定.node
模块的依赖关系。
我在Dependency Walker中加载了edge_nativeclr.node
,并注意到VCRUNTIME140.DLL
(Visual Studio 2015 C运行时)。 Edge.js附带了msvcr120.dll
,Visual Studio 2013 C运行时,但我一直在重建模块,并将msvs_version
设置为2015。
一旦我把副本vcruntime140.dll
在同一目录edge_nativeclr.node
,一切开始工作正常。
即使我确实安装了VC ++ Redistributable x64,我也遇到了这个错误。 事实证明,我的情况下的错误实际上并不是一个问题,因为一切正常(我能够使用电子边缘运行电子快速启动应用程序)。
即便如此,作者已修复安装,以便不会发生错误。 https://github.com/kexplo/electron-edge/issues/25#issuecomment-272908409
另外请注意,如果在Dependency Walker中加载edge_nativeclr.node,您将看到VCRUNTIME140.DLL已正确解析(例如,在我的PC上的C:\\ Windows \\ System32下)。 但是,您可能会看到几个问号和错误。 事实证明,这些只是由于Dependency Walker的一些限制而不是实际问题。 请参阅Dependency Walker:缺少dll
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.