如何使用Auth0配置SystemJS? [英] How configure SystemJS with Auth0?

查看:82
本文介绍了如何使用Auth0配置SystemJS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I tried configure SystemJS for Auth0 (angular2-jwt) and Angular 2.0.0-beta.6 but always I get the following error:

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文档但我不确定如何解决此问题.

In addition, I have read the SystemJS documentation but I am not sure about how to fix this issue.

推荐答案

似乎您没有同时导入 angular2/http 脚本:

It seems you are not importing angular2/http script along the others:

<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 -->

别忘了引导它,否则您将得到:

Don't forget to bootstrap it, or else you'll get:

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

EXCEPTION: No provider for Http! (AppComponent -> Http)
...
Error: DI Exception ...

引导它:

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

bootstrap(AppComponent, [HTTP_PROVIDERS]);

这篇关于如何使用Auth0配置SystemJS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆