asar icon indicating copy to clipboard operation
asar copied to clipboard

Unpacked paths that include the Windows \\?\ hack to support long paths do not resolve

Open grantcv1 opened this issue 8 years ago • 4 comments

I believe my issue is related to https://github.com/electron/asar/issues/75, but nobody is responding to my comments on that issue.

I am getting the following error when I try and run my installed app on Windows:

Uncaught Error: The specified module could not be found. \?\C:\Users\myuserid\AppData\Local\Programs\MyApp\resources\app.asar.unpacked\AmdGen\node_modules\java\build\Release\nodejavabridge_bindings.node at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20) at Object.Module._extensions..node (module.js:598:18) at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Object. (C:\Users\myuserid\AppData\Local\Programs\MyApp\resources\app.asar.unpacked\AmdGen\node_modules\java\lib\nodeJavaBridge.js:21:16) at Object. (C:\Users\myuserid\AppData\Local\Programs\MyApp\resources\app.asar.unpacked\AmdGen\node_modules\java\lib\nodeJavaBridge.js:316:3) GUI.js:33 Uncaught TypeError: Cannot read property 'on' of undefined at onLoad (GUI.js:33) at onload (Index.html:8)

I have verified that the nodejavabridge_bindings.node file has indeed been unpacked and exists at the path specified.

Note: The \?\ prefix before the C: is apparently a hack from Microsoft that triggers proper support for long paths. I'm not sure what is adding that prefix as it appears from the stack trace that the path started without it and it was added before calling dlopen in ELECTRON_ASAR.js where the failure apparently happens. (https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath)

I am using electron-builder to create my installer.

I tried resolving this problem by manually adding the following to the "build" portion of my package.json file before building the installer:

"asar": true,
"asarUnpack": "**\\*.node",

That did not help.

My suspicion is that the \?\ prefix has, at some point, been introduced to allow electron (or Node.js) to support long paths on the Windows platform, but something in the dlopen() method inside ELECTRON_ASAR.js doesn't understand this weird notation.

I'm currently at electron version 1.7.5 and electron-builder version 19.20.1.

grantcv1 avatar Sep 12 '17 16:09 grantcv1

It is not a bug of asar after my 2 day digging. In my case, I use node-java.It throw flowing error:

Uncaught Error: %1 is not a valid Win32 application.
\\?\F:\tmp\test\win-ia32-unpacked\resources\app\node_modules\java\build\Release\nodejavabridge_bindings.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (F:\tmp\test\win-ia32-unpacked\resources\app\node_modules\java\lib\nodeJavaBridge.js:21:16)
    at Object.<anonymous> (F:\tmp\test\win-ia32-unpacked\resources\app\node_modules\java\lib\nodeJavaBridge.js:316:3)

I flow laggingreflex's idea. https://github.com/soldair/node-qrcode/issues/22 native module can not be load because it's dependences was missing. U can use dependencywalker to found out what denpendences was missing, and try to copy to path of entry or add to system path environment variable!

MichaelIT avatar Oct 20 '17 08:10 MichaelIT

In my case with node sqlcipher, I got this error on Window 7 Uncaught Error: The specified module could not be found. \\?\C:\Users\Administrator\AppData\Local\Temp\68C3.tmp.node

Problem was due to missing dll. Adding these to application folder solved it.

icudt57.dll icuin57.dll icuuc57.dll libeay32.dll msvcp120.dll msvcr120.dll ssleay32.dll

vuamitom avatar Dec 22 '17 02:12 vuamitom

if you use electron-builder, you can use config.extraFiles, copy files from your node addon directory(include dll) to electron root.

{
  from: 'src/addon',
  to: './'
}

Sanford284 avatar Jul 18 '23 15:07 Sanford284

The reason for this error may be the .node file cannot find its required .dll files.

LZQCN avatar Nov 14 '23 18:11 LZQCN