electron / asar

Simple extensive tar-like archive format with indexing
MIT License
2.54k stars 244 forks source link

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

Closed grantcv1 closed 4 weeks ago

grantcv1 commented 7 years ago

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.

MichaelIT commented 6 years ago

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!

vuamitom commented 6 years ago

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

Sanford284 commented 1 year ago

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: './'
}
LZQCN commented 10 months ago

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

MarshallOfSound commented 4 weeks ago

Closing this old issue as it is likely fixed by now, if not please raise a new issue.