Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load native extension when using asar #424

Closed
codehz opened this issue Jul 13, 2016 · 12 comments
Closed

Cannot load native extension when using asar #424

codehz opened this issue Jul 13, 2016 · 12 comments
Labels
feature:asar Related to the ASAR feature needs info Issue reporter needs to provide more information for maintainers to take action question ❓ Question about using Electron Packager. Not supported in this issue tracker.

Comments

@codehz
Copy link

codehz commented Jul 13, 2016

ELECTRON_ASAR.js:158
Uncaught Error: The specified module could not be found.
?\C:\Users\AppData\Local\Temp.tmp.node

And I can found it in this path..

I think the \\?\ is unnecessary..

It appears only when I use this option --asar=true

Which version of electron-packager are you using?

7.3.0

What CLI arguments are you passing? Alternatively, if you are using the API, what parameters are
you passing to the packager() function?

electron-packager . "VizMusicPlayer" --out=dist/win --platform=win32 --arch=x64 --version=1.2.7 --icon=build/icon.ico --asar=true

What version of Electron are you building with?

1.2.7

What is the host platform are you running electron-packager on?

Windows 10 x64

What target platform(s)/architecture(s) are you building for?

Windows x64

Is there a stack trace in the error message you're seeing?

(RUNTIME, Electron Renderer Process)

ELECTRON_ASAR.js:158
Uncaught Error: The specified module could not be found.
\\?\C:\Users\<User Name>\AppData\Local\Temp\<RANDOM>.tmp.node

Please provide either a failing testcase or detailed steps to reproduce your problem.

https://github.com/VizMusicPlayer/VizMusicPlayer

@develar
Copy link
Contributor

develar commented Jul 13, 2016

So... do you use electron-builder or electron-packager — electron-userland/electron-builder#580 ? It seems it is your app issue, not packaging tool issue.

@malept malept added needs info Issue reporter needs to provide more information for maintainers to take action feature:asar Related to the ASAR feature question ❓ Question about using Electron Packager. Not supported in this issue tracker. and removed needs info Issue reporter needs to provide more information for maintainers to take action labels Jul 13, 2016
@malept
Copy link
Member

malept commented Jul 13, 2016

@develar it's pretty obvious from the link that this person uses electron-packager, not electron-builder.

@codehz if you use asar, you need to whitelist native extensions like sharp (they do not work, see the Electron docs for why). Check out the --asar.unpack parameter. According to another section in the same Electron docs, try --asar.unpack=*.node (I have not tested it though).

@malept malept changed the title Uncaught Error: The specified module could not be found. Cannot load native extension when using asar Jul 13, 2016
@codehz
Copy link
Author

codehz commented Jul 13, 2016

@malept
I have try to add --asar.unpack=*.node, but Still Not Working.

ELECTRON_ASAR.js:158 Uncaught Error: The specified module could not be found.
\\?\D:\x\desktop\VizMusicPlayer\dist\win\Viz Music Player-win32-x64\resources\app.asar.unpacked\node_modules\sharp\build\Release\sharp.node

I think \\?\ is the core problem....\\?\ prefix should be delete

@malept malept added the needs info Issue reporter needs to provide more information for maintainers to take action label Jul 13, 2016
@malept
Copy link
Member

malept commented Jul 13, 2016

Try electron-packager 7.2.0 and use --asar-unpack instead of --asar.unpack. There was a change to asar options in 7.3.0 but it shouldn't have impacted functionality.

@malept
Copy link
Member

malept commented Jul 13, 2016

Also, with electron-packager 7.3.0, don't specify --asar=true and --asar.unpack=*.node at the same time.

@codehz
Copy link
Author

codehz commented Jul 13, 2016

I have used below(7.3.0)

> electron-packager . "Viz Music Player" --app-version=0.0.1 --prune --out=dist/win --platform=win32 --arch=x64 --version=1.2.7 --icon=build/icon.ico --version-string.CompanyName="CodeHz.one" --versio
n-string.ProductName="Viz Music Player" --version-string.FileDescription="Viz Music Player" --overwrite --asar.unpack=*.node

(same as before)
and now using 7.2.0 try below

> electron-packager . "Viz Music Player" --app-version=0.0.1 --prune --out=dist/win --platform=win32 --arch=x64 --version=1.2.7 --icon=build/icon.ico --version-string.CompanyName="CodeHz.one" --versio
n-string.ProductName="Viz Music Player" --version-string.FileDescription="Viz Music Player" --overwrite --asar=true --asar-unpack=*.node

(Not work, same as before)
and this

> electron-packager . "Viz Music Player" --app-version=0.0.1 --prune --out=dist/win --platform=win32 --arch=x64 --version=1.2.7 --icon=build/icon.ico --version-string.CompanyName="CodeHz.one" --versio
n-string.ProductName="Viz Music Player" --version-string.FileDescription="Viz Music Player" --overwrite  --asar-unpack=*.node

The last one does work, but it does not used asar...

@malept
Copy link
Member

malept commented Jul 13, 2016

I'm not seeing a difference between the second and third command.

@codehz
Copy link
Author

codehz commented Jul 13, 2016

Sorry, I have removed --asar , but forget to update comment....

@malept
Copy link
Member

malept commented Jul 13, 2016

Yes, for electron-packager 7.2.0 and below, it is required to use --asar if you want asar support.

This seems like a problem with the asar module. Electron Packager does not transform the options that are passed to the asar module at all.

@drFabio
Copy link

drFabio commented Jul 27, 2016

I can confirm that is an Asar issue not electron-packager issue, I am using asar programatically and having the same behaviour. Also I am having this issue on windows 7 but not on windows 10

@vuamitom
Copy link

Please note that this same error can be thrown if dll dependencies are not found for the native node module.

Details are in last comment on

electron/asar#129

@Joeanca
Copy link

Joeanca commented Sep 17, 2018

After much searching and reading documentation --asar.unpack=*.{node,dll} on the electron-packager cli did the trick for me. Make sure you are rebuilding sharp as required before packaging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:asar Related to the ASAR feature needs info Issue reporter needs to provide more information for maintainers to take action question ❓ Question about using Electron Packager. Not supported in this issue tracker.
Projects
None yet
Development

No branches or pull requests

6 participants