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

vague errors executing my first windows electron exe #293

Open
laurencefass opened this issue Jun 27, 2024 · 0 comments
Open

vague errors executing my first windows electron exe #293

laurencefass opened this issue Jun 27, 2024 · 0 comments

Comments

@laurencefass
Copy link

laurencefass commented Jun 27, 2024

Ive recently installed capacitor vscode extension and trying to work with minimal documentation to create an electron image.

To keep things simple i used the sidemenu template from the vscode ionic extension. I have proven this works on web and as an Android image.

There appear to be a lot of steps missing from the cap-electron docs to get dist executable but ive tried piecing things together from the internet and AI and came up with this package.json

{
  "name": "sidemenu",
  "version": "1.0.0",
  "description": "An Amazing Capacitor App",
  "author": {
    "name": "",
    "email": ""
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "license": "MIT",
  "main": "build/src/index.js",
  "scripts": {
    "build": "tsc && electron-rebuild",
    "electron:start-live": "node ./live-runner.js",
    "electron:start": "npm run build && electron --inspect=5858 ./",
    "electron:pack": "npm run build && electron-builder build --dir -c ./electron-builder.config.json",
    "electron:make": "npm run build && electron-builder build -c ./electron-builder.config.json -p always",
    "electron:build": "electron-builder"
  },
  "dependencies": {
    "@capacitor-community/electron": "^5.0.0",
    "chokidar": "~3.5.3",
    "electron-is-dev": "~2.0.0",
    "electron-serve": "~1.1.0",
    "electron-unhandled": "~4.0.1",
    "electron-updater": "^5.3.0",
    "electron-window-state": "^5.0.3"
  },
  "devDependencies": {
    "electron": "^26.2.2",
    "electron-builder": "~23.6.0",
    "typescript": "^5.0.4"
  },
  "keywords": [
    "capacitor",
    "electron"
  ],
  "build": {
    "appId": "com.yourapp.id",
    "productName": "YourAppName",
    "directories": {
      "output": "dist"
    },
    "files": [
      "build/**/*",
      "main.js"
    ],
    "win": {
      "target": [
        "nsis",
        "portable"
      ]
    }
  }
}

i used electron-builder to create the image. I have no idea if this is correct, current or best practice but it did produce exe outputs referenced above.

root@vps765527:/docker/apps-root/capacitor/apps/sidemenu/electron# npx electron-builder --win
  • electron-builder  version=23.6.0 os=4.19.0-26-cloud-amd64
  • loaded configuration  file=package.json ("build" field)
  • electron-rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies

To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`
  • writing effective config  file=dist/builder-effective-config.yaml
  • packaging       platform=win32 arch=x64 electron=26.6.10 appOutDir=dist/win-unpacked
  • default Electron icon is used  reason=application icon is not set
  • building        target=nsis file=dist/YourAppName Setup 1.0.0.exe archs=x64 oneClick=true perMachine=false
  • building        target=portable file=dist/YourAppName 1.0.0.exe archs=x64
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.4.1/nsis-3.0.4.1.7z size=1.3 MB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.4.1/nsis-3.0.4.1.7z duration=920ms
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z size=731 kB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z duration=938ms
  • building block map  blockMapFile=dist/YourAppName Setup 1.0.0.exe.blockmap

I have managed to get an app.exe and an app Setup.exe in the dist folder and copied across my windows os.

When I run the exe first error is:

image

which when i copy the error reads:

Unhandled Promise Rejection
Error: ENOENT: no such file or directory, open 'C:/Users/user/AppData/Local/Temp/2iSquBK1PUzJ9fhE8MYHOmMnKWK/resources/app-update.yml'

The app then loads with no rendering

image

It would be great to get an idea on how to do this properly.

Thanks

@laurencefass laurencefass changed the title numerous errors executing my first windows electron exe vague errors executing my first windows electron exe Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant