简体   繁体   English

空白屏幕 - Angular JIT 编译失败:'@angular/compiler' 未加载

[英]Blank Screen - Angular JIT compilation failed: '@angular/compiler' not loaded

I'm currently having trouble getting my Ionic 5 along with Angular 9 project to work.我目前无法让我的 Ionic 5 和 Angular 9 项目一起工作。

ionic cordova run android works great ionic cordova run android效果很好

but as soon i run ionic cordova run android --prod the only thing i get is a blank screen.但是一旦我运行ionic cordova run android --prod我唯一得到的是一个空白屏幕。

Output from chrome dev tools:来自 chrome 开发工具的 Output:

Error: Angular JIT compilation failed: '@angular/compiler' not loaded!
  - JIT compilation is discouraged for production use-cases! Consider AOT mode instead.
  - Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?

  - Alternatively provide the compiler with 'import "@angular/compiler";' before bootstrapping.
    at J (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at Function.get (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at Gt (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at Ji (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at main-es2015.a75ef42b05ed5a68eecb.js:1
    at Yi.processProvider (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at main-es2015.a75ef42b05ed5a68eecb.js:1
    at main-es2015.a75ef42b05ed5a68eecb.js:1
    at Array.forEach (<anonymous>)
    at Ot (main-es2015.a75ef42b05ed5a68eecb.js:1)

I already checked the following solution approaches, but none of them worked for my project:我已经检查了以下解决方案,但它们都不适用于我的项目:

if i set aot and buildOptimizer to false in angular.js i can run ionic cordova run android --prod without any error, but when i then try to generate an apk with ionic cordova build android --prod --release and open it, the screen is blank again. if i set aot and buildOptimizer to false in angular.js i can run ionic cordova run android --prod without any error, but when i then try to generate an apk with ionic cordova build android --prod --release and open it,屏幕又是一片空白。

My current dependencies in package.json are:我当前在 package.json 中的依赖项是:

  "dependencies": {
    "@angular/common": "~9.1.6",
    "@angular/core": "~9.1.6",
    "@angular/forms": "~9.1.6",
    "@angular/platform-browser": "~9.1.6",
    "@angular/platform-browser-dynamic": "~9.1.6",
    "@angular/router": "~9.1.6",
    "@auth0/angular-jwt": "^4.1.2",
    "@capacitor/core": "3.0.0",
    "@ionic-native/app-version": "^5.36.0",
    "@ionic-native/core": "^5.36.0",
    "@ionic-native/device": "^5.36.0",
    "@ionic-native/in-app-browser": "^5.36.0",
    "@ionic-native/ionic-webview": "^5.36.0",
    "@ionic-native/local-notifications": "^5.36.0",
    "@ionic-native/native-audio": "^5.36.0",
    "@ionic-native/network": "^5.36.0",
    "@ionic-native/screen-orientation": "^5.36.0",
    "@ionic-native/splash-screen": "^5.36.0",
    "@ionic-native/status-bar": "^5.36.0",
    "@ionic/angular": "^5.0.0",
    "@ionic/storage": "^2.3.1",
    "@types/google-maps": "^3.2.2",
    "@types/hammerjs": "^2.0.39",
    "compare-func": "^2.0.0",
    "cordova-android": "^9.0.0",
    "cordova-ios": "^5.1.1",
    "cordova-plugin-androidx": "^2.0.0",
    "cordova-plugin-androidx-adapter": "^1.1.1",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-device-name": "^1.3.5",
    "cordova-plugin-fcm-with-dependecy-updated": "^7.3.1",
    "cordova-plugin-inappbrowser": "^4.1.0",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-local-notification": "^0.9.0-beta.2",
    "cordova-plugin-nativeaudio": "^3.0.9",
    "cordova-plugin-network-information": "^2.0.2",
    "cordova-plugin-screen-orientation": "^3.0.2",
    "cordova-plugin-wkwebviewxhrfix": "git+https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix.git",
    "cordova-support-google-services": "^1.3.2",
    "es6-promise-plugin": "^4.2.2",
    "hammerjs": "^2.0.8",
    "ionic-pullup": "^5.0.0-beta.3",
    "ionic2-calendar": "^0.6.9",
    "phonegap-plugin-multidex": "^1.0.0",
    "rxjs": "~6.5.1",
    "rxjs-compat": "^6.5.5",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },

M< environment looks like: M< 环境如下所示:

Ionic:

   Ionic CLI                     : 5.4.16 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 5.9.1
   @angular-devkit/build-angular : 0.901.15
   @angular-devkit/schematics    : 9.1.15
   @angular/cli                  : 9.1.15
   @ionic/angular-toolkit        : 2.3.3

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0, ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 18 other plugins)

Am i missing something?我错过了什么吗? Any help is welcome!欢迎任何帮助!

I got everything working after following these steps:遵循以下步骤后,我得到了一切工作:

  • renamed folders node_modules, www and platforms/android (for backup reasons)重命名文件夹 node_modules、www 和 platform/android(出于备份原因)
  • npm install npm安装
  • ionic cordova prepare android离子 cordova 准备 android
  • ionic cordova run android --prod离子 cordova 运行 android --prod

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular JIT 编译失败:未加载“@angular/compiler” - Angular JIT compilation failed: '@angular/compiler' not loaded 带有 Angular 9 的 Ionic 5 - Angular JIT 编译失败:“@angular/compiler”未加载 - Ionic 5 with Angular 9 - Angular JIT compilation failed: '@angular/compiler' not loaded 未捕获错误:Angular JIT 编译失败:'@angular/compiler' 未加载 - Uncaught Error: Angular JIT compilation failed: '@angular/compiler' not loaded ERROR 错误:Angular JIT 编译失败:'@angular/compiler' 未加载 - ERROR Error: Angular JIT compilation failed: '@angular/compiler' not loaded 未捕获(承诺):错误:Angular JIT 编译失败:'@angular/compiler' 未加载! 在 angular 9 - Uncaught (in promise): Error: Angular JIT compilation failed: '@angular/compiler' not loaded! in angular 9 Angular 9 未处理的 Promise 拒绝:Angular JIT 编译失败错误 - Angular 9 Unhandled Promise rejection: Angular JIT compilation failed error 为什么Angular 2的模板具有JiT编译功能? - Why does Angular 2 have JiT compilation for templates? Angular 5的默认编译是什么? (AOT或JIT) - What is the default compilation for Angular 5? (AOT or JIT) 错误:执行 AngularJS 到 Angular 13 迁移时,JIT 编译因可注入 class PlatformLocation {} 失败 - Error:JIT compilation failed for injectable class PlatformLocation {} while doing AngularJS to Angular 13 migration Angular AOT和JIT编译器有什么区别 - What is the difference between Angular AOT and JIT compiler
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM