【问题标题】:404 GET /traceur but not telling me where Angular 2404 GET /traceur 但没有告诉我 Angular 2 在哪里
【发布时间】:2016-09-20 22:25:04
【问题描述】:

我收到了404 GET /traceur,但我无话可说。我把它贴在 GIT 上,以防有人想看。

GIT_HUB Link

systemjs.config.js

(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'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.ts',
        defaultExtension: 'ts'
      },
      rxjs: {
        defaultExtension: 'js'
      },
      'angular2-in-memory-web-api': {
        main: './index.js',
        defaultExtension: 'js'
      }
    }
  });
})(this);

tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": true,
        "suppressImplicitAnyIndexErrors": true,
        "outDir": "build"
    },
    "exclude": [
        "app/node_modules",
        "typings/main",
        "typings/main.d.ts"
    ]
}

您可以看到 outDir 正在构建,并且查看 SOF 这个错误意味着无法加载某些内容。但是它并没有告诉我什么无法加载,所以我迷路了。我是否需要更多配置,因为我使用的是outDir

【问题讨论】:

  • 404 traceur 错误通常是由于缺少导入,或者您的某个类中的导入错误。你可以查看这个问题的答案:stackoverflow.com/questions/37022526/…它可能会对你有所帮助。
  • 你能把map obj中的app: 'app',改成app: 'build',吗?
  • 谢谢@micronyks 我必须这样做然后更改packages main: to main.js 并且它正在工作。现在我再次收到Can't resolve all parameters for TypeDecorator 错误。猜猜回到绘图板上。
  • 如果你认为它解决了你的问题,我会把它作为未来读者的答案,如果不是这样的话。你说什么?
  • 我认为对于TypeDecorator error,您可能会提出一个新问题,因为我认为它与其他问题有关。需要检查更多和关注的代码。

标签: angular


【解决方案1】:

这是我必须改变的:

 map: {
      // our app is within the app folder
      app: 'build',

      // 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'
    },
    // 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'
      }
    }

由于我在 tsconfig.json 中使用了 outDir,因此我不得不更改查找 jsmap 文件的位置。

ts 中的 cmets 也是/** */ 而不是/* */,这也可能导致错误。

这个错误意味着某些东西不能被加载,它没有告诉你在哪里。

【讨论】:

    猜你喜欢
    • 2017-03-03
    • 1970-01-01
    • 2011-07-28
    • 1970-01-01
    • 2020-05-29
    • 2015-04-13
    • 1970-01-01
    • 1970-01-01
    • 2017-01-11
    相关资源
    最近更新 更多