INFO Launching Electron…

(node:24312) [DEP0128] DeprecationWarning: Invalid ‘main’ field in ‘C:\xxx\dist_electron\package.json’ of ‘background.js’. Please either fix that or report it to the module author

(Use electron --trace-deprecation ... to show where the warning was created)

解决办法

以上是在说同级目录有index.js文件存在,需要更改electron主进程文件名。 在开发过程中,dist_electron目录会生成两个文件:index.js和package.json,冲突就在这个文件夹,所以我们只需要把index.js文件名修改成background.js就可以了

在vue.config.js

pluginOptions: {
    electronBuilder: {
        chainWebpackMainProcess: (config) => {
            config.output.filename('background.js');
        }
    }
}
Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐