【问题标题】:Ionic 4 + Electron not worksIonic 4 + Electron 不起作用
【发布时间】:2019-08-06 08:09:05
【问题描述】:

我在开始一个新的 Electron + Ionic 项目时遇到问题。

我已按照本教程进行操作:

https://www.9lessons.info/2018/10/ionic-electron-desktop-app.html

但是当我使用命令运行项目时:

npm run electron-serve

我在开发工具控制台上收到此错误并且屏幕是白色的:

  runtime-es2015.33b5e618b3baf74c7138.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.

main-es2015.64da9645e917002baf25.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.

polyfills-es2015.1b94da7ab13e05353bf7.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.

/Users/myuser/ionic/Frontend/myproject/src/myproject/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/renderer/security-warnings.js:145 Electron Security Warning (Insecure Content-Security-Policy) This renderer process has either no Content Security
    Policy set or a policy with "unsafe-eval" enabled. This exposes users of
    this app to unnecessary security risks.

For more information and help, consult
https://electronjs.org/docs/tutorial/security.
 This warning will not show up
once the app is packaged.
(anonymous) @ /Users/myuser/ionic/Frontend/myproject/src/myproject/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/renderer/security-warnings.js:145

会做错什么?

【问题讨论】:

    标签: ionic-framework electron ionic4


    【解决方案1】:

    简单,只需转到 src/tsconfig.json -> 将行“target”:“es2015”更改为“target”:“es5”,然后在终端和应用程序上重新运行“npm run electron-serve”应该工作。

    这适用于 Windows 10、Ionic 5.2.7、Electron 6.0.10

    【讨论】:

      【解决方案2】:

      对于有同样问题的人:

      并不是真正的电容器错误,而是与 Angular 8 构建设置与电子不兼容有关的构建问题。

      将tsconfig.json中的target从es2015改为es5,或者添加

      "browserslist": [
        "> 5%"
      ]
      

      在 package.json 中

      Related

      解决问题

      【讨论】:

        猜你喜欢
        • 2019-01-20
        • 2019-01-08
        • 1970-01-01
        • 1970-01-01
        • 2019-12-28
        • 2018-04-10
        • 2019-01-03
        • 1970-01-01
        • 2020-02-27
        相关资源
        最近更新 更多