node.jselectronasar

How to unpack an .asar file?


I have packed my Electron application using the following command:

asar pack app app.asar

Now, I need to unpack it and get the whole code back. Is there any way to do so?


Solution

  • From the asar documentation

    (the use of npx here is to avoid to installing the @electron/asar tool globally with npm install -g @electron/asar)

    Extract the whole archive:

    npx @electron/asar extract app.asar <destfolder>
    

    Extract a particular file:

    npx @electron/asar extract-file app.asar main.js