简体   繁体   English

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

[英]platform-browser-dynamic.umd.js - 404 after updating packages in Angular2 tutorial

I started following Angular2 tutorial a while ago.不久前我开始关注 Angular2 教程。 Now that I've come back to it and got to the Routing chapter , it seems like the tutorial has been updated slightly and I had to go back and update package.json to the current version or the app.routes.ts file wouldn't compile.现在我已经回到它并进入了路由章节,似乎教程已经稍微更新了,我不得不返回并将package.json更新到当前版本,否则app.routes.ts文件将不会编译。 Now it compiles fine but when I run the application, scripts crash at runtime, apparently inside the Zone.js package:现在它编译得很好,但是当我运行应用程序时,脚本在运行时崩溃,显然在 Zone.js 包中:

在此处输入图片说明

I've checked and the platform-browser-dynamic.umd.js file indeed doesn't exist on disk.我已经检查过,磁盘上确实不存在platform-browser-dynamic.umd.js文件。

This is the new package.json file:这是新的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"
  }
}

I've tried using the longer version from the tutorial's GitHub repository , but the error is the same.我尝试使用 教程的 GitHub 存储库中的较长版本,但错误是相同的。 Although the vanilla GitHub project builds and runs fine.尽管 vanilla GitHub 项目构建和运行良好。

I've made sure my <script > tags in index.html match the ones on GitHub:我已经确保index.html中的<script > 标签与 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>

My typings.json file:我的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"
  }
}

How can I get rid of this error?我怎样才能摆脱这个错误? My Angular2 experience so far consisting in copying code from the tutorial like a monkey, I don't really understand what this error relates to...到目前为止,我的 Angular2 经验包括像猴子一样从教程中复制代码,我真的不明白这个错误与什么有关......

Your Angular2 app was not able to load platform-browser-dynamic.umd.js as well as your other umd bundles as they were moved to the bundles/ subdirectory in 2.0.0-rc.2 .您的 Angular2 应用程序无法加载platform-browser-dynamic.umd.js以及其他 umd 包, 因为它们被移动2.0.0-rc.2bundles/子目录。

As you already noticed your error was inside your system.config.js as it was trying to load the umd bundles using the wrong path ( see here ).正如你已经注意到你的错误在你的system.config.js因为它试图使用错误的路径加载 umd 包( 见这里)。

Copying the new config file should have added the '/bundles/' + part which does resolve your issue.复制新的配置文件应该添加了'/bundles/' +部分,它确实可以解决您的问题。

我还必须对system.config.js进行猴子复制: https : //github.com/angular/quickstart/blob/master/src/systemjs.config.js

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)

Well, I came across the above issues.嗯,我遇到了上述问题。 To fix it, delete browser cache and hit f5 in the visual studio.要修复它,请删除浏览器缓存并在 Visual Studio 中按 f5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM