electron打包后起打开是白屏

首先:ctrl+shft+i调出程序控制台,看报错。

如果是:

Cannot find module 'ws'

Require stack:

        - electron/js2c/renderer_init

    at Module._resolveFilename (internal/modules/cjs/loader.js:887:15)
    at Function.o._resolveFilename (electron/js2c/renderer_init.js:33:1118)
    at Module._load (internal/modules/cjs/loader.js:732:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12684)
    at Function.o._load (electron/js2c/renderer_init.js:33:379)
    at Module.require (internal/modules/cjs/loader.js:959:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Module.6422 (app://./js/422.37914361.js:1:16871)
    at Function.n (app://./js/app.def4f4b9.js:1:7443)

可以在vue.config.js里(我的是在这里,根据自己情况而定),主要是在pluginOptions的electronBuilder里加入`externals: ['没有打包进去的包名']`,

添加如下代码:

pluginOptions: {
    electronBuilder: {

      externals: ['ws']
    }
}

 参考了「1999笃行」的原创文章

你可能感兴趣的:(前端,electron,javascript,前端)