platform-b​​rowser-dynamic.umd.js - 在更新Angular2教程中的包之后的404

时间:2016-07-10 10:08:08

标签: angularjs angular npm

我刚开始关注Angular2教程。现在我已回到它并进入Routing chapter,似乎教程已略有更新,我不得不返回并将package.json更新为current version或者app.routes.ts文件不会编译。现在它编译得很好但是当我运行应用程序时,脚本在运行时崩溃,显然在Zone.js包中:

enter image description here

我已经检查过,platform-browser-dynamic.umd.js文件确实不存在于磁盘上。

这是新的package.json文件:

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/forms": "0.2.0",
    "@angular/http": "2.0.0-rc.4",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
    "@angular/router": "3.0.0-beta.1",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.4",
    "systemjs": "0.19.27",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "zone.js": "^0.6.12",
    "angular2-in-memory-web-api": "0.0.14",
    "bootstrap": "^3.3.6"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.2.0",
    "typescript": "^1.8.10",
    "typings":"^1.0.4"
  }
}

我尝试过使用the longer version from the tutorial's GitHub repository,但错误是一样的。虽然vanilla GitHub项目构建并运行良好。

我确定了<script&gt; index.html中的标签与GitHub上的标签匹配:

<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>
<script src="node_modules/systemjs/dist/system.src.js"></script>

<script src="systemjs.config.js"></script>

我的typings.json文件:

{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160317120654",
    "jasmine": "registry:dt/jasmine#2.2.0+20160505161446",
    "node": "registry:dt/node#4.0.0+20160509154515"
  }
}

如何摆脱这个错误?到目前为止,我的Angular2体验包括像猴子一样复制教程中的代码,我真的不明白这个错误与...有什么关系...

3 个答案:

答案 0 :(得分:6)

您的Angular2应用无法将platform-browser-dynamic.umd.js以及其他umd捆绑as they were moved加载到bundles/中的2.0.0-rc.2子目录。

正如您已经注意到,您的错误位于system.config.js内部,因为它尝试使用错误的路径(see here)加载umd捆绑包。

复制新的配置文件应添加'/bundles/' +部分,这样可以解决您的问题。

答案 1 :(得分:1)

node_modules/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js Failed to load resource: the server responded with a status of 404 (Not Found)

index.html:18 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:51412/src/node_modules/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js
Error: XHR error (404 Not Found)

嗯,我遇到了上述问题。要解决此问题,请删除浏览器缓存,然后在Visual Studio中按f5键。

答案 2 :(得分:0)