electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.73k stars 1.74k forks source link

My main.js file isn't inside app.asar #8642

Closed asjhita closed 1 month ago

asjhita commented 1 month ago

This is my code:

{
  "name": "quizlet",
  "version": "1.0.0",
  "description": "The app for the flashcard learning app, Quizlet",
  "author": "Quizlet",
  "keywords": [
    "quizlet",
    "flashcard",
    "learning"
  ],
  "license": "MIT",
  "main": "main.js",
  "scripts": {
    "test": "playwright test",
    "build": "electron-builder",
    "start": "electron .",
    "create-installer": "electron-installer-windows --src release-builds/quizlet-win32-x64 --dest installers/"
  },
  "devDependencies": {
    "@electron/packager": "^18.3.5",
    "@playwright/test": "^1.48.2",
    "electron": "^33.0.2",
    "electron-builder": "^25.1.8",
    "electron-installer-windows": "^3.0.0"
  },
  "build": {
    "productName": "Quizlet",
    "appId": "com.quizlet.id",
    "asar": false,
    "asarUnpack": [
      "main.js"
    ],
    "extraResources": [
      {
        "from": "main.js",
        "to": "main.js"
      }
    ],
    "files": [
      "dist/**/*",
      "node_modules/**/*",
      "main.js",
      "icon/**/*"
    ],
    "directories": {
    "output": "dist"
    },
    "win": {
      "target": "nsis",
      "icon": "./icon/favicon.ico"
    },
    "mac": {
      "target": [
        "dmg",
        "zip"
      ],
      "icon": "./icon/mac.icns"
    },
    "linux": {
      "target": [
        "AppImage",
        "deb",
        "rpm"
      ],
      "icon": "./icon/android-chrome-512x512.png"
    }
  }
}

I should probably use web hosted images but that is not my problem. The main.js file won't go in the app.asar file because I keep getting the error message:

Application entry file "main.js" <all that stuff>\<my project name>\dist\win-unpacked\resources\app.asar" does not exist. Seems like a wrong configuration.

I even tried to manually unpack app.asar, put the main.js in the extract folder and then repack it but when I ran the script, it had just left the app.asar and it was in the resources folder with app.asar instead of in it. The code I ran to achieve this:

npm run build --win

Please help me fix this problem. Thank you.

mmaietta commented 1 month ago

Can you confirm that it doesn't work when you remove this from your config? As that's what's causing the main.js to not be in the asar AND also in the resources folder instead.

    "asar": false,
    "asarUnpack": [
      "main.js"
    ],
    "extraResources": [
      {
        "from": "main.js",
        "to": "main.js"
      }
    ],

If you could provide a minimum reproducible repo, that'd be a great start for me to be able to investigate from. This sounds like a local configuration issue though

asjhita commented 1 month ago

Very sorry for the issue, I had fixed it and found it was indeed a local configuration error instead. Although I fixed it, I decided to use NSIS instead of electron/builder because it wouldn't accept my 2056x2056 image or my 512x512 so I have it sorted out and thank you for your help.