从Ionic 2.2.0升级到3.0.1打破一切。奇怪的错误

时间:2017-04-22 01:18:35

标签: ionic-framework ionic2 angularfire2

所以我按照这里的说明进行操作:https://github.com/driftyco/ionic/blob/master/CHANGELOG.md#steps-to-upgrade2

升级并确保我使用最新的CLI测试版后,当我输入Ionic服务时,这就是错误:

Runtime Error
Cannot find module "../../node_modules/@angular/core/src/metadata/di"
Stack
Error: Cannot find module "../../node_modules/@angular/core/src/metadata/di"
    at g (http://localhost:8100/build/polyfills.js:3:7133)
    at Object.<anonymous> (http://localhost:8100/build/main.js:91192:7)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.<anonymous> (http://localhost:8100/build/main.js:90791:73)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.<anonymous> (http://localhost:8100/build/main.js:161802:70)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.defineProperty.value (http://localhost:8100/build/main.js:66:18)
    at http://localhost:8100/build/main.js:69:10
Ionic Framework: 3.0.1
Ionic App Scripts: 1.3.4
Angular Core: 4.0.0
Angular Compiler CLI: 4.0.0
Node: 7.5.0
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

供参考。这是我的package.json文件:

"dependencies": {
    "@angular/animations": "4.0.0",
    "@angular/common": "4.0.0",
    "@angular/compiler": "4.0.0",
    "@angular/compiler-cli": "4.0.0",
    "@angular/core": "4.0.0",
    "@angular/forms": "4.0.0",
    "@angular/http": "4.0.0",
    "@angular/platform-browser": "4.0.0",
    "@angular/platform-browser-dynamic": "4.0.0",
    "@angular/platform-server": "4.0.0",
    "@ionic-native/core": "^3.4.2",
    "@ionic-native/google-plus": "^3.4.4",
    "@ionic-native/in-app-browser": "^3.5.0",
    "@ionic-native/keyboard": "^3.5.0",
    "@ionic-native/social-sharing": "^3.5.0",
    "@ionic-native/splash-screen": "3.4.2",
    "@ionic-native/status-bar": "^3.4.2",
    "@ionic/storage": "2.0.1",
    "angular2-elastic": "^0.13.0",
    "angularfire2": "^2.0.0-beta.8",
    "firebase": "^3.8.0",
    "font-awesome": "^4.7.0",
    "imgcache.js": "^1.0.0",
    "ionic-angular": "3.0.1",
    "ionic-image-loader": "^1.7.2",
    "ionicons": "^3.0.0",
    "ng2-cordova-oauth": "0.0.8",
    "ng2-validation": "^3.8.0",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.4",
    "typescript": "2.2.2"
  },

我暂停了由AngularFire引起的错误b / c在运行npm install时出现此警告:

npm WARN angularfire2@2.0.0-beta.8 requires a peer of @angular/common@^2.0.0 but none was installed.
npm WARN angularfire2@2.0.0-beta.8 requires a peer of @angular/compiler@^2.0.0 but none was installed.
npm WARN angularfire2@2.0.0-beta.8 requires a peer of @angular/core@^2.0.0 but none was installed.
npm WARN angularfire2@2.0.0-beta.8 requires a peer of @angular/platform-browser@^2.0.0 but none was installed.
npm WARN angularfire2@2.0.0-beta.8 requires a peer of @angular/platform-browser-dynamic@^2.0.0 but none was installed.

但我不知道什么是继续引用不在Angular 4中的di文件!!请帮忙!

2 个答案:

答案 0 :(得分:1)

我认为问题出在您的ionic-image-loader软件包中,该软件包目前位于1.7.2。 根据{{​​3}},changelog here中的当前版本为3.1.1

它已升级为在npm中使用ionic-native版本3。尝试升级此软件包。

ng2-validation也移动到2.0.0中的角度4。

您可能需要根据更改日志重构您的应用。

答案 1 :(得分:1)

经过整夜的调试,我发现了这个问题。以下是此问题的原因:IDE自动导入语句。我使用Webstorm,它会自动为我导入所有内容。由于它们崩溃并隐藏了大项目的导入,我错过了这个问题。因此,如果你有类似的导入问题(它可以是任何东西,不仅仅是元数据/ di,它也发生在我的@ angular / form / ...上),在问题陈述上进行完整的项目搜索。对我来说就是这条线:

import {ViewChild} from "../../node_modules/@angular/core/src/metadata/di"

我把它改成

import {ViewChild} from "@angular/core"

错误消失了。希望这有助于其他人将他们的项目从Angular 2.x转移到Angular 4.x.