首页 文章

systemjs无法加载我的模块

提问于
浏览
0

systemjs.config.js:

/**
 * System configuration for Angular 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',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'mystartup_commons': 'npm:mystartup_commons'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        defaultExtension: 'js'
      },
      rxjs: {
       defaultExtension: 'js'
      },
      mystartup_commons: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

这是它指向的index.js:

"use strict";
function __export(m) {
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./helpers"));
__export(require("./model2"));

浏览器出错:

GET http:// localhost:3000 / node_modules / mystartup_commons / dist / src / helpers 404(Not Found)GET http:// localhost:3000 / node_modules / mystartup_commons / dist / src / helpers 404(Not Found)

1 回答

  • 0

    您将 mystartup_commons 指向文件,而不是包 . 因此 defaultExtension 没有太大作用 .

    试试 jspm ,它会告诉你如何设置东西 .

    当您使用TS和SystemJS时,此问题也可能会“引起”您的兴趣:

    https://github.com/systemjs/systemjs/issues/1587

相关问题