错误:找不到指定的模块 [英] Error: The specified module could not be found

查看:45
本文介绍了错误:找不到指定的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用edge.js执行一些.NET代码,以便在电子应用程序的Windows上打印。我已经尝试了electron-edge,我也尝试了在instructions in the Electron docs之后手动构建针对Electron的edge.js模块,但是当我尝试在打包的应用程序中使用EDGE时,我一直收到以下错误:

Error: The specified module could not be found.
\?C:path	oappapp-1.0.0
esourcesapp.asar.unpacked
ode_modulesedgelib
ativewin32x646.5.0edge_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模块确实存在。我怀疑我不知何故没有正确构建模块,它可能仍然以错误的Node版本为目标,因此电子无法导入模块。

我尝试了几种不同的方法,包括按照electron-edge's steps手动更新build.bat并将--target=1.4.12 --dist-url=https://atom.io/download/atom-shell标志添加到node-gypconfigure 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#217electron/electron#892得到一些提示,指出当本机模块缺少依赖项(如.dll)时,可能会出现这个错误"无法找到指定的模块",并且您可以使用Dependency Walker检查任何给定.node模块的依赖项。

我在Dependency Walker中加载了edge_nativeclr.node,并注意到缺少Visual Studio 2015 C运行时VCRUNTIME140.DLL。Edge.js附带了Visual Studio 2013 C运行时msvcr120.dll,但我一直在重新构建模块,并将msvs_version设置为2015。

我将vcruntime140.dll的副本放在与edge_nativeclr.node相同的目录中后,一切都开始正常工作。

这篇关于错误:找不到指定的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆