我正在尝试为我的离子应用程序构建生产版本。如果我运行我的应用程序,一切正常:
离子运行android
但是当我尝试使用
构建我的生产应用程序时离子运行android --prod
我收到此错误:
无法读取属性' componentType'未定义的 main.js:7
我的应用程序一直停留在Splash Screen
这是我的package.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"
}
答案 0 :(得分:0)
命令为build
而不是run
。
尝试:
ionic build android --release --prod
run
将在您连接的设备或模拟器中构建并运行
答案 1 :(得分:0)
问题在于" page-name.module.ts"使用"离子生成页面时创建的文件"命令。 手动创建页面并再次运行它(离子运行android --prod)或(ionic build android --prod)。 它对我有用。 他们很快就修好了。