【问题标题】:Mapping sockjs-client in systemjs在 systemjs 中映射 sockjs-client
【发布时间】:2016-09-18 20:46:21
【问题描述】:

我正在使用 typescript 和 angular2,我想在我的项目中使用 SockJS。我跑:npm install sockjs-client。现在我想在systemjs.config.js 中添加node_modules/sockjs-client 的映射。这是文件现在的样子:

/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
    System.config({
        paths: {
            // paths serve as alias
            'npm:': 'node_modules/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            app: 'app',
            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
            // other libraries
            'rxjs':                       'npm:rxjs',
            'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
            'sockjs-client': 'npm:sockjs-client',
            'stompjs': 'npm:stompjs/lib/stomp.min.js'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: './main.js',
                defaultExtension: 'js'
            },
            rxjs: {
                defaultExtension: 'js'
            },
            'angular2-in-memory-web-api': {
                main: './index.js',
                defaultExtension: 'js'
            }
        }
    });
})(this);

我在浏览器中有以下异常:

localhost/:16 Error: Error: XHR error (404 Not Found) loading http://localhost:8080/node_modules/sockjs-client(…)

sockjs-client 库的正确 systemjs 映射是什么?

【问题讨论】:

    标签: node.js angular typescript sockjs


    【解决方案1】:

    试试:

    'sockjs-client': 'npm:sockjs-client/dist/sockjs.js'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-03
      • 1970-01-01
      • 1970-01-01
      • 2017-01-28
      • 2016-08-31
      • 1970-01-01
      • 2016-09-02
      相关资源
      最近更新 更多