Electron-packager: Cannot load native extension when using asar

Created on 13 Jul 2016  Â·  12Comments  Â·  Source: electron/electron-packager

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

asar needs info question

Most helpful comment

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.

All 12 comments

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

@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
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

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.

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

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...

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

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

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.

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

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wgrhstf picture wgrhstf  Â·  4Comments

ghost picture ghost  Â·  3Comments

leanderBehr picture leanderBehr  Â·  3Comments

andreabisello picture andreabisello  Â·  3Comments

rafaelcastrocouto picture rafaelcastrocouto  Â·  3Comments