Angular2无法更新到RC7 - zone.js &reflect-metadata

Angular2 Failing to update to RC7 - zone.js & reflect-metadata

本文关键字:zone js reflect-metadata RC7 更新 Angular2      更新时间:2023-09-26

我正试图让我的应用程序运行与新的RC7的角,但我似乎不能得到它完成,因为控制台喊道:

Promise rejection: Zone.assertZonePatched is not a function      angular2-polyfills.js:489

不知怎么的消失时,这个会弹出:

Reflect.getMetadata is not a function (..)                                core.umd.js:472

看起来实现改变了,我的没有更新,虽然我npm install从头开始,更新我的package.json如下:

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "build": "webpack",
    "start": "webpack-dev-server",
    "typings": "typings",
    "postinstall": "typings install"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0-rc.7",
    "@angular/compiler": "2.0.0-rc.7",
    "@angular/core": "2.0.0-rc.7",
    "@angular/forms": "2.0.0-rc.7",
    "@angular/http": "2.0.0-rc.7",
    "@angular/platform-browser": "2.0.0-rc.7",
    "@angular/platform-browser-dynamic": "2.0.0-rc.7",
    "@angular/router": "3.0.0-rc.3",
    "@angular/upgrade": "2.0.0-rc.7",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "^0.6.21",
    "angular2-in-memory-web-api": "0.0.19",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.3",
    "angular2": "2.0.0-beta.17",
    "angular2-apollo": "^0.4.6",
    "apollo-client": "^0.4.13",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.35.1",
    "moment": "^2.14.1",
    "source-map-loader": "^0.1.5"
  },
  "devDependencies": {
    "ts-loader": "^0.8.2"
  }
}

index.html:(我也试着从unpkg.com获取包,没有成功)

<html>
  <head>
    <title>My App</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.3/css/bootstrap.min.css"
          integrity="sha384-MIwDKRSSImVFAZCVLtU0LMDdON6KVCrZHyVQQj6e8wIEJkW4tvwqXrbMIya1vriY" crossorigin="anonymous">
    <link rel="stylesheet" href="style.css">
    <!-- 1. Load libraries -->
    <!-- IE required polyfills, in this exact order -->
    <script src="node_modules/es6-shim/es6-shim.min.js"></script>
    <script src="https://www.atlasestateagents.co.uk/javascript/tether.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.3/js/bootstrap.min.js"
            integrity="sha384-ux8v3A6CPtOTqOzMKiuo3d/DomGaaClxFYdCu2HPMBEkf6x2xiDyJ7gkXU0MWwaD" crossorigin="anonymous"></script>
    <script src="node_modules/core-js/client/shim.min.js"></script>
    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>
  </head>
  <!-- 3. Display the application -->
  <body>
    <my-app>Loading...</my-app>
  </body>
  <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
  <script src="dist/bundle.js"></script>
</html>

你知道怎么解决这个问题吗?

提前感谢!:)

注释:

  • 按包计算。你不需要angular2 .js
  • 删除"angular2": "2.0.0-beta. "17",从 package.json
  • 删除 angular2-polyfills.js index . html

    <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    

事实上,如果你在node_modules下有angular2文件夹,那么删除该文件夹。最新的angular2包将在node_modules下的@angular文件夹中提供。