How to run and pack external executable using Electron?

前端 未结 2 745
有刺的猬
有刺的猬 2021-01-05 21:14

For example, I have a compiled binary cudaDeviceQuery which returns a list of devices as JSON. Here\'s a piece of code:

export default function          


        
2条回答
  •  伪装坚强ぢ
    2021-01-05 22:00

    There are two things. If you set __dirname: true in your web app config you will get the relative path of the file from your context directory

    If you set __dirname: false then __dirname will have the full path.

    Development Mode

    You have two options

    1. Set __dirname: true and concatenate it with os.cwd()
    2. Set __dirname: false and use __dirname directly

    Production Mode

    1. Set __dirname: true and use os.cwd().
    2. Set __dirname: true and use process.resourcePath

    I will prefer 2 as the preferred approach in production

提交回复
热议问题