Angular2 beta - bootstrapping HTTP_PROVIDERS - “Unexpected Token <”

给你一囗甜甜゛ 提交于 2019-11-28 10:43:42
Eric Martinez

This error occurs when you try to import something that is not being included in your HTML when using SystemJS. Module bundlers like Webpack handle all that for you.

For your case you have to add the Http bundle that's a separated bundle, for example

<script src="https://code.angularjs.org/2.0.0-beta.0/http.dev.js"></script>

You'll see this same error when trying to use the router and you forgot to add the router bundle.

Check the difference between these two configurations from @pkozlowski-opensource's repos

  • Using SystemJS : For this case he would've to add http bundle, or router bundle if he wanted to use them.
  • Using Webpack : In this case Webpack bundles everything in that bundle.js file for you.

Glad it helped.

E. Fortes

If you're using npm, include a script tag with the http reference to your local installation:

<script src="node_modules/angular2/bundles/http.dev.js"></script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!