【问题标题】:Not been Able to Build Production Build for my ionic 2 app无法为我的 ionic 2 应用程序构建生产版本
【发布时间】:2017-08-09 22:26:40
【问题描述】:

我正在尝试为我的 ionic 应用程序构建生产版本。如果我运行我的应用程序,一切正常:

离子运行 android

但是当我尝试使用

构建我的生产应用程序时

离子运行 android --prod

我收到此错误:

无法读取未定义的属性“componentType” main.js:7.

我的应用停留在启动画面

这是我的 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"
}

【问题讨论】:

    标签: android angular typescript ionic-framework ionic2


    【解决方案1】:

    命令是build 而不是run。 试试:

    ionic build android --release --prod
    

    run 将在您连接的设备或模拟器中构建和运行

    【讨论】:

    • 如果我使用上述命令构建它,然后对其进行签名并尝试在设备中安装,即使它在启动画面处停止,
    • 你在任何地方都使用componentType吗?
    • 它只是在 main.js 中,我在我的应用程序中没有其他地方使用过它
    • 你能把你的 package.json 添加到问题中吗?
    • 我已经添加了我的 package.json
    【解决方案2】:

    问题在于使用“ionic generate page”命令时创建的“page-name.module.ts”文件。 手动创建页面并再次运行它(ionic run android --prod)或(ionic build android --prod)。 它对我有用。 回家,他们很快就会修好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-06
      • 2022-08-16
      • 2019-01-07
      • 2017-09-24
      • 2020-06-09
      • 1970-01-01
      • 2018-04-10
      • 2017-11-28
      相关资源
      最近更新 更多