【问题标题】:How configure SystemJS with Auth0?如何使用 Auth0 配置 SystemJS?
【发布时间】:2016-02-29 01:05:29
【问题描述】:

我尝试为 Auth0 (angular2-jwt) 和 Angular 2.0.0-beta.6 配置 SystemJS,但总是出现以下错误:

GET http://localhost:3000/angular2/http 404 (Not Found)fetchTextFromURL @ system.src.js:1068(anonymous function) @ system.src.js:1649lib$es6$promise$$internal$$initializePromise @ angular2-polyfills.js:515lib$es6$promise$promise$$Promise @ angular2-polyfills.js:806(anonymous function) @ system.src.js:1648(anonymous function) @ system.src.js:2669(anonymous function) @ system.src.js:3233(anonymous function) @ system.src.js:3500(anonymous function) @ system.src.js:4116(anonymous function) @ system.src.js:4324(anonymous function) @ system.src.js:4564(anonymous function) @ system.src.js:326Zone.run @ angular2-polyfills.js:1243zoneBoundFn @ angular2-polyfills.js:1220lib$es6$promise$$internal$$tryCatch @ angular2-polyfills.js:468lib$es6$promise$$internal$$invokeCallback @ angular2-polyfills.js:480lib$es6$promise$$internal$$publish @ angular2-polyfills.js:451(anonymous function) @ angular2-polyfills.js:123Zone.run @ angular2-polyfills.js:1243zoneBoundFn @ angular2-polyfills.js:1220lib$es6$promise$asap$$flush @ angular2-polyfills.js:262
angular2-polyfills.js:1243 Error: XHR error (404 Not Found) loading http://localhost:3000/angular2/http(…)

SystemJS:

<script>
    //configure system loader
    System.config({
      packages: {
        app: {
            format: 'register',
            defaultExtension: 'js'
        },
        'angular2-jwt': {
            defaultExtension: 'js'
        }
      },
      map: {
        'angular2-jwt': 'node_modules/angular2-jwt/angular2-jwt.js'
      }
    });
  </script>

另外,我已经阅读了SystemJS documentation,但我不确定如何解决这个问题。

【问题讨论】:

  • 显示其他&lt;script&gt;标签,带有src的标签。

标签: javascript npm angular systemjs


【解决方案1】:

您似乎没有将angular2/http 脚本与其他脚本一起导入:

<script src="https://code.angularjs.org/2.0.0-beta.6/angular2.dev.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.6/http.js"></script> <!-- add this -->

别忘了引导它,否则你会得到:

例外:没有 Http 提供程序! (AppComponent -> Http)
...
错误:DI 异常 ...

引导它:

import {bootstrap}    from 'angular2/platform/browser'
import {HTTP_PROVIDERS} from 'angular2/http';
import {AppComponent} from './app.component'

bootstrap(AppComponent, [HTTP_PROVIDERS]);

【讨论】:

  • 如果使用 ES5:ng.platform.browser.bootstrap(AppComponent, [ng.http.HTTP_PROVIDERS]);
  • &lt;script src="https://code.angularjs.org/2.0.0-beta.6/http.js"&gt;&lt;/script&gt; 一起工作!
猜你喜欢
  • 2021-07-29
  • 1970-01-01
  • 2017-10-05
  • 1970-01-01
  • 2017-01-25
  • 1970-01-01
  • 2021-10-31
  • 2020-06-29
  • 1970-01-01
相关资源
最近更新 更多