capacitor-community / electron

Deploy your Capacitor apps to Linux, Mac, and Windows desktops, with the Electron platform! 🖥️
https://capacitor-community.github.io/electron/
MIT License
318 stars 58 forks source link

Error build electron app #286

Closed adityofr9 closed 1 month ago

adityofr9 commented 1 month ago

Summary the issues I have an issue with my project, where I am using Angular Ionic as the renderer and have installed the latest version of Sqlite3 on Electron. When running it in the dev live server environment, it works well.

However, the problem I am facing is that I am unable to build the app using the commands:

$ npm run electron:pack "electron:pack": "npm run build && electron-builder build --dir -c ./electron-builder.config.json",

or

$ npm run electron:make "electron:make": "npm run build && electron-builder build -c ./electron-builder.config.json -p always"

Results

$ npm run electron:pack

> my-app@1.0.0 electron:pack
> npm run build && electron-builder build --dir -c ./electron-builder.config.json

> my-app@1.0.0 build
> tsc && electron-rebuild -f -w sqlite3

✔ Rebuild Complete
  • electron-builder  version=23.6.0 os=10.0.22631
  • loaded configuration  file=D:\my-app\electron\electron-builder.config.json
  • 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
  • rebuilding native dependencies  dependencies=sqlite3@5.1.7 platform=win32 arch=x64
  • install prebuilt binary  name=sqlite3 version=5.1.7 platform=win32 arch=x64 napi=
  • build native dependency from sources  name=sqlite3
                                          version=5.1.7
                                          platform=win32
                                          arch=x64
                                          napi=
reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 7.1.2
    prebuild-install warn This package does not support N-API version 36
    prebuild-install warn install prebuilt binaries enforced with --force!
    prebuild-install warn install prebuilt binaries may be out of date!
    prebuild-install info looking for local prebuild @ prebuilds\sqlite3-v5.1.7-napi-v36-win32-x64.tar.gz
    prebuild-install info looking for cached prebuild @ C:\Users\USER\AppData\Local\npm-cache\_prebuilds\69004f-sqlite3-v5.1.7-napi-v36-win32-x64.tar.gz
    prebuild-install http request GET https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v36-win32-x64.tar.gz
    prebuild-install http 404 https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v36-win32-x64.tar.gz
    prebuild-install warn install No prebuilt binaries found (target=36 runtime=napi arch=x64 libc= platform=win32)

  ⨯ cannot execute  cause=exit status 1
                    errorOut=npm ERR! code 1
    npm ERR! path D:\my-app\electron\node_modules\sqlite3
    npm ERR! command failed
    npm ERR! command C:\Windows\system32\cmd.exe /d /s /c prebuild-install -r napi || node-gyp rebuild
    npm ERR! prebuild-install warn This package does not support N-API version 26.6.10
    npm ERR! prebuild-install warn install No prebuilt binaries found (target=26.6.10 runtime=napi arch=x64 libc= platform=win32)
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@8.4.1
    npm ERR! gyp info using node@20.11.0 | win32 | x64
    npm ERR! gyp ERR! find Python
    npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
    npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
    npm ERR! gyp ERR! find Python checking if "python3" can be used
    npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
    npm ERR! gyp ERR! find Python checking if "python" can be used
    npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
    npm ERR! gyp ERR! find Python checking if Python is C:\Users\USER\AppData\Local\Programs\Python\Python39\python.exe
    npm ERR! gyp ERR! find Python - "C:\Users\USER\AppData\Local\Programs\Python\Python39\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python39\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files\Python39\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Users\USER\AppData\Local\Programs\Python\Python39-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Users\USER\AppData\Local\Programs\Python\Python39-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python39-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files\Python39-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python39-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files (x86)\Python39-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Users\USER\AppData\Local\Programs\Python\Python38\python.exe
    npm ERR! gyp ERR! find Python - "C:\Users\USER\AppData\Local\Programs\Python\Python38\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python38\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files\Python38\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Users\USER\AppData\Local\Programs\Python\Python38-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python38-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files\Python38-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python38-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files (x86)\Python38-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Users\USER\AppData\Local\Programs\Python\Python37\python.exe
    npm ERR! gyp ERR! find Python - "C:\Users\USER\AppData\Local\Programs\Python\Python37\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python37\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files\Python37\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Users\USER\AppData\Local\Programs\Python\Python37-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Users\USER\AppData\Local\Programs\Python\Python37-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python37-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files\Python37-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python37-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files (x86)\Python37-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Users\USER\AppData\Local\Programs\Python\Python36\python.exe
    npm ERR! gyp ERR! find Python - "C:\Users\USER\AppData\Local\Programs\Python\Python36\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python36\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files\Python36\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Users\USER\AppData\Local\Programs\Python\Python36-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python36-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files\Python36-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python36-32\python.exe
    npm ERR! gyp ERR! find Python - "C:\Program Files (x86)\Python36-32\python.exe" could not be run
    npm ERR! gyp ERR! find Python checking if the py launcher can be used to find Python 3
    npm ERR! gyp ERR! find Python - "py.exe" is not in PATH or produced an error
    npm ERR! gyp ERR! find Python
    npm ERR! gyp ERR! find Python **********************************************************
    npm ERR! gyp ERR! find Python You need to install the latest version of Python.
    npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
    npm ERR! gyp ERR! find Python you can try one of the following options:
    npm ERR! gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"
    npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
    npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
    npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
    npm ERR! gyp ERR! find Python   npm config set python "C:\Path\To\python.exe"
    npm ERR! gyp ERR! find Python For more information consult the documentation at:
    npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
    npm ERR! gyp ERR! find Python **********************************************************
    npm ERR! gyp ERR! find Python
    npm ERR! gyp ERR! configure error
    npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
    npm ERR! gyp ERR! stack     at PythonFinder.fail (D:\my-app\electron\node_modules\sqlite3\node_modules\node-gyp\lib\find-python.js:330:47)
    npm ERR! gyp ERR! stack     at PythonFinder.runChecks (D:\my-app\electron\node_modules\sqlite3\node_modules\node-gyp\lib\find-python.js:159:21)
    npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:\my-app\electron\node_modules\sqlite3\node_modules\node-gyp\lib\find-python.js:228:18)
    npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (D:\my-app\electron\node_modules\sqlite3\node_modules\node-gyp\lib\find-python.js:294:16)
    npm ERR! gyp ERR! stack     at exithandler (node:child_process:430:5)
    npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:442:5)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:518:28)
    npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:484:16)
    npm ERR! gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    npm ERR! gyp ERR! System Windows_NT 10.0.22631
    npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\my-app\\electron\\node_modules\\sqlite3\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"     
    npm ERR! gyp ERR! cwd D:\my-app\electron\node_modules\sqlite3
    npm ERR! gyp ERR! node -v v20.11.0
    npm ERR! gyp ERR! node-gyp -v v8.4.1
    npm ERR! gyp ERR! not ok

    npm ERR! A complete log of this run can be found in: C:\Users\USER\AppData\Local\npm-cache\_logs\2024-05-21T10_35_27_699Z-debug-0.log

                    command='C:\Program Files\nodejs\node.exe' 'C:\Users\USER\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js' rebuild sqlite3@5.1.7
                    workingDir=

package.json image

Node Version

Additional context Sorry for any mistakes of post writing, this is my first post. And I need help for my work purpose

Additional notes

Thx

adityofr9 commented 1 month ago

I've done this issues with installing Microsoft Visual Studio 2022 with workload Dekstop development with C++, nothing do with that.

And another issues that i notice is the electron builder not able to http request GET https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v36-win32-x64.tar.gz

then i found this https://github.com/TryGhost/node-sqlite3/issues/1746#issuecomment-2090423625 but to fix that i need to change the directory target into C:\Users\USER\AppData\Local\npm-cache_prebuilds\69004f-sqlite3-v5.1.7-napi-v36-win32-x64.tar.gz like on the console of error message. Build is successfully but am facing another issue again 🤣

333780242-dc41f6ce-ce87-4230-889b-1ba5237414a6

this time i have no idea about this

adityofr9 commented 1 month ago

Nvm i figured it out by myself, so I'm still don't get it about what unhandled function on this framework built for. The error message not showing clear the main problem, my first thought is the wrong configuration of capacitor but it doesn't work at all. Until I realized the error message only showing the app custom protocol only. Yes only show failed loading app custom protocol, just it. This is completely a dead end.

So the actual problem is there is an error on your app logic, but this error popup message doesn't tell what happen on your app, so you must figured it out what the problem is... like a fortune-teller hahah