[英]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.