无法构建离子应用程序 - AngularFire2构建错误

时间:2017-05-30 21:37:29

标签: android cordova angularfire2 ionic3

我开始在我的Ionic App中使用firebase。一切正常,我可以在浏览器中使用该应用程序。但是,每当我尝试使用命令ionic cordova build android为Android构建应用程序时,它会显示如下构建错误:

Error: ./~/firebase/app/shared_promise.js
Module not found: Error: Can't resolve 'promise-polyfill' in 'D:\mychat\node_modules\firebase\app'
resolve 'promise-polyfill' in 'D:\mychat\node_modules\firebase\app'
  Parsed request is a module
  using description file: D:\mychat\node_modules\firebase\package.json (relative path: ./app)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: D:\mychat\node_modules\firebase\package.json (relative path: ./app)
    resolve as module
      looking for modules in D:\mychat\node_modules
        using description file: D:\mychat\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: D:\mychat\package.json (relative path: ./node_modules)
          using description file: D:\mychat\package.json (relative path: ./node_modules/promise-polyfill)
            as directory
              D:\mychat\node_modules\promise-polyfill doesn't exist
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              D:\mychat\node_modules\promise-polyfill doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              D:\mychat\node_modules\promise-polyfill.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              D:\mychat\node_modules\promise-polyfill.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              D:\mychat\node_modules\promise-polyfill.json doesn't exist
[D:\mychat\node_modules\promise-polyfill]
[D:\mychat\node_modules\promise-polyfill]
[D:\mychat\node_modules\promise-polyfill.ts]
[D:\mychat\node_modules\promise-polyfill.js]
[D:\mychat\node_modules\promise-polyfill.json]
 @ ./~/firebase/app/shared_promise.js 37:35-62
 @ ./~/firebase/app/firebase_app.js
 @ ./~/firebase/app.js
 @ ./~/firebase/auth.js
 @ ./~/angularfire2/auth/auth.js
 @ ./~/angularfire2/auth.js
 @ ./src/app/app.module.ts
 @ ./src/app/main.ts

这是我的package.json:

{
  "name": "mychat",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "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/common": "4.1.2",
    "@angular/compiler": "4.1.2",
    "@angular/compiler-cli": "4.1.2",
    "@angular/core": "4.1.2",
    "@angular/forms": "4.1.2",
    "@angular/http": "4.1.2",
    "@angular/platform-browser": "4.1.2",
    "@angular/platform-browser-dynamic": "4.1.2",
    "@ionic-native/core": "3.7.0",
    "@ionic-native/splash-screen": "3.7.0",
    "@ionic-native/status-bar": "3.7.0",
    "@ionic/storage": "2.0.1",
    "angularfire2": "^4.0.0-rc.0",
    "cordova-android": "^6.2.3",
    "cordova-plugin-console": "^1.0.5",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-statusbar": "^2.2.2",
    "cordova-plugin-whitelist": "^1.3.1",
    "firebase": "^4.0.0",
    "ionic-angular": "3.3.0",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.10"
  },
  "devDependencies": {
    "@angular/cli": "^1.0.6",
    "@ionic/app-scripts": "1.3.7",
    "@ionic/cli-plugin-cordova": "1.2.1",
    "@ionic/cli-plugin-ionic-angular": "1.2.0",
    "typescript": "2.3.3"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-console": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "ionic-plugin-keyboard": {}
    },
    "platforms": [
      "android"
    ]
  }
}

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

正如@nickmcblain在评论中所建议的那样,我所要做的就是安装promise-polyfill并且构建工作正常。