Skip to content

Cannot load native extension when using asar #424

Closed

Description

@codehz

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

Activity

  1. develar commented on Jul 13, 2016

    @develar
    Contributor

    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.

  2. added
    needs info
    feature:asar
    question ❓
    and removed
    needs info
    on Jul 13, 2016
  3. malept commented on Jul 13, 2016

    @malept
    Member

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

  4. changed the title [-]Uncaught Error: The specified module could not be found.[/-] [+]Cannot load native extension when using asar[/+] on Jul 13, 2016
  5. codehz commented on Jul 13, 2016

    @codehz
    Author

    @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

  6. added
    needs info
    on Jul 13, 2016
  7. malept commented on Jul 13, 2016

    @malept
    Member

    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.

  8. malept commented on Jul 13, 2016

    @malept
    Member

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

  9. codehz commented on Jul 13, 2016

    @codehz
    Author

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

  10. malept commented on Jul 13, 2016

    @malept
    Member

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

  11. codehz commented on Jul 13, 2016

    @codehz
    Author

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

  12. malept commented on Jul 13, 2016

    @malept
    Member

    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.

  13. drFabio commented on Jul 27, 2016

    @drFabio

    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

  14. vuamitom commented on Dec 22, 2017

    @vuamitom

    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

  15. Joeanca commented on Sep 17, 2018

    @Joeanca

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:asarneeds infoquestion ❓

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions