我正在尝试为我的 ionic 应用程序构建生产版本。 如果我使用以下命令运行我的应用程序,一切正常:
离子运行安卓
但是当我尝试使用
离子运行安卓--产品
我收到此错误:
无法读取未定义的属性"组件类型" 主.js:7。
我的应用卡在初始屏幕
这是我的包.json
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/compiler-cli": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/platform-server": "2.2.1",
"@ionic/cloud-angular": "^0.11.0",
"@ionic/storage": "1.1.7",
"angular2-focus": "^1.0.3",
"angular2-moment": "^1.1.0",
"ionic-angular": "2.0.0-rc.4",
"ionic-gallery-modal": "0.0.7",
"ionic-native": "2.2.11",
"ionicons": "3.0.0",
"rxjs": "5.0.0-beta.12",
"sw-toolbox": "3.4.0",
"zone.js": "0.6.26"
},
"devDependencies": {
"@ionic/app-scripts": "1.0.0",
"typescript": "2.0.9"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-statusbar",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": [],
"description": "App: An Ionic project"
}
命令build
不是run
。尝试:
ionic build android --release --prod
run
将在连接的设备或模拟器中生成和运行
问题出在使用"ionic generate page"命令时创建的"page-name.module.ts"文件。手动创建页面并再次运行它(ionic run android --prod(或(ionic build android --prod(。它对我有用。回家他们很快就修好了。