无法使用SystemJS在客户端上提供Auth0依赖性

时间:2016-09-12 15:24:16

标签: express systemjs auth0

我有一个基于Angular2和Express的网络应用程序。我正在尝试实现安全的API端点,并且欺骗并使用Auth0。我正在关注guide,但是,我似乎没有按照我的设置进行操作。我的应用程序目前正在崩溃:

  

GET / angular2-jwt 404 30.433 ms - 14

尽管我有system.config.js

(function (global) {
  System.config({
    paths: {
      'npm:': 'node_modules/'
    },
    map: {
      app: 'app',
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      //all the other angular packages
      'angular2-jwt':               'node_modules/angular2-jwt/angular2-jwt.js',
      'rxjs':                       'npm:rxjs',
      'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api'
    },
    packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js'
      },
      rxjs: {
         main: 'Rx.js',
        defaultExtension: 'js'
      },
      'angular2-in-memory-web-api': {
        main: './index.js',
        defaultExtension: 'js'
      },
      'angular2-jwt': { defaultExtension: 'js' }
    }
  });
})(this);

为什么我的system.config.js没有工作,或者我误解了如何使用systemJS?

我的 index.html 包含:

<script src="./config/systemjs.config.js"></script>
<script>
  System.import('app').catch(function(err){ console.error(err); });
</script>

如果我在system.config的System.config({行的正上方添加了console.log消息,则不会触发它。这是否意味着我的system.config没有被读取?

1 个答案:

答案 0 :(得分:0)

你在system.config.js中输入错误:

  'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api'
},no extension
packages: {

当我删除no extension时,它会按预期请求

GET /node_modules/angular2-jwt/angular2-jwt.js
  

如果我在System.config上直接添加一个console.log消息({system of my system.config,它不会被触发。这是否意味着我的system.config没有被读取?

很有可能,是的。您可以通过查看浏览器中开发人员工具中的网络活动选项卡来检查它 - 应该有一个请求获取systemjs.config.js。

您可以在https://github.com/fictitious/test-systemjs-angular找到一个工作导入的示例(但它不会进行任何身份验证)。