简体   繁体   English

Angular 2 Webpack演示不起作用

[英]Angular 2 Webpack demo not working

I have completed steps for official tutorial and I got error: 我已经完成了官方教程的步骤,但出现错误:

Failed to load app.component.html ; Zone: <root> ; Task: Promise.then ; Value: Failed to load app.component.html undefined

My Github Repo 我的Github回购

I have spotted another web page on web with same problem: Example 我在网络上发现了另一个具有相同问题的网页: 示例

Could problem be in Angular itself? 问题可能出在Angular本身吗?

I traced the issue by starting to "debug" angular2-template-loader with console log adding: console.log("+++++++"+source); 我通过添加控制台日志开始“调试” angular2-template-loader来跟踪该问题:console.log(“ +++++++” + source); just after the function definition. 在函数定义之后。 By doing it I saw that not all the ts file were processed and in particular app.component.ts. 通过这样做,我看到并不是所有的ts文件都得到了处理,尤其是app.component.ts。

Then I saw in the src folder .js and .map files, so I deleted it and added in the tsconfig.json those properties after compilerOptions (outside it): "compileOnSave": false, "buildOnSave": false 然后,我在src文件夹.js和.map文件中看到了,所以我将其删除,并在tsconfig.json中的那些属性后添加了compileOptions(在其外部):“ compileOnSave”:false,“ buildOnSave”:false

Run again npm start and now the application loads successfully. 再次运行npm start,现在应用程序已成功加载。

@TeodorKolev: I cloned your repo, npm install and npm start and replicated the error. @TeodorKolev:我克隆了您的存储库,npm install和npm start并复制了错误。 I deleted the .js and .map files created, then added the properties and then npm start again and now it's working. 我删除了创建的.js和.map文件,然后添加了属性,然后再次启动npm,现在可以正常工作了。

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

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