我将ionic 4项目升级为使用angular 7,一切都在调试模式下工作,但是当我尝试进行生产编译时: 'ionic cordova build android --prod',我得到以下输出:
ionic-app-scripts build --prod --target cordova --platform android [20:24:15] ionic-app-scripts 3.2.4 ... [20:24:44]打字稿错误 找不到“ @types”的类型定义文件。
[20:24:44] ionic-app-script任务:“构建” [20:24:44]错误:无法翻译TypeScript 错误:无法翻译TypeScript 在errorCheckProgram(/Users/jesusotero/Projects/Bambuco/confiar/mardeconfianza/app/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:119:39) 在对象。 (/Users/jesusotero/Projects/Bambuco/confiar/mardeconfianza/app/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:89:21) 在步骤(/Users/jesusotero/Projects/Bambuco/confiar/mardeconfianza/app/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23) 在Object.next(/Users/jesusotero/Projects/Bambuco/confiar/mardeconfianza/app/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53) 完成时(/Users/jesusotero/Projects/Bambuco/confiar/mardeconfianza/app/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58) [ERROR]运行子流程ionic-app-scripts时发生错误。
ionic-app-scripts build --prod --target cordova --platform android退出代码为1。
我一直无法找到解决该问题的方法,因此,如果那里有人可以帮助我正确地解决该问题,我将非常感激。 我的package.json是:
{
"name": "xxxxxxx",
"version": "1.0.2",
"author": "xxxxxx",
"homepage": "xxxxx",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/animations": "7.2.15",
"@angular/cli": "^7.3.9",
"@angular/common": "7.2.15",
"@angular/compiler": "7.2.15",
"@angular/compiler-cli": "7.2.15",
"@angular/core": "7.2.15",
"@angular/forms": "7.2.15",
"@angular/http": "7.2.15",
"@angular/platform-browser": "7.2.15",
"@angular/platform-browser-dynamic": "7.2.15",
"@ionic-native/android-full-screen": "^5.6.0",
"@ionic-native/core": "^5.6.0",
"@ionic-native/mobile-accessibility": "^5.6.0",
"@ionic-native/splash-screen": "^5.6.0",
"@ionic-native/status-bar": "^5.6.0",
"@ionic/pro": "1.0.20",
"@ionic/storage": "2.1.3",
"@ngx-translate/core": "^9.1.1",
"@ngx-translate/http-loader": "^2.0.1",
"cordova-android": "~7.0.0",
"cordova-ios": "4.5.5",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-fullscreen": "^1.2.0",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^2.3.1",
"cordova-plugin-network-information": "git+https://github.com/apache/cordova-plugin-network-information.git",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"ionic-angular": "^3.9.6",
"ionicons": "3.0.0",
"phonegap-plugin-mobile-accessibility": "^1.0.5",
"rxjs": "6.5.2",
"rxjs-compat": "^6.0.0-rc.0",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.29"
},
"devDependencies": {
"@ionic/app-scripts": "^3.2.4",
"@types/node": "^12.0.2",
"typescript": "^3.2.4"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-fullscreen": {},
"phonegap-plugin-mobile-accessibility": {},
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"cordova-plugin-statusbar": {}
},
"platforms": [
"android",
"ios"
]
}
}
离子信息:
Ionic:
ionic (Ionic CLI) : 4.12.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.6
@ionic/app-scripts : 3.2.4
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.0.5, cordova-plugin-ionic-webview 2.3.1, (and 7 other plugins)
System:
NodeJS : v10.11.0 (/usr/local/Cellar/node/10.11.0/bin/node)
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 10.2.1 Build version 10E1001
答案 0 :(得分:1)
根据您共享的项目数据,是Ionic 3项目(3.9.6)。
Ionic 3并不是要与Angular 6+一起使用。
我建议检查Ionic 3参考应用程序的package.json并相应地降级您的依赖项。
答案 1 :(得分:1)
ionic-app-script最近进行了更新,产生了此错误。
作为一种解决方法,您可以将package.json中的版本锁定为最后一个可用的版本:
“ @ ionic / app-scripts”:“ 3.2.3”
或降级
答案 2 :(得分:0)
解决方案:使用ionic serve
服务您的项目,然后更新src文件夹中的任何.ts文件并保存(ctrl + s),它将自动再次构建并服务该应用程序,并且错误将得到解决,希望: )。
这解决了我的问题。
引自ionic框架论坛上发布的说明。