Angular 2 - 404 traceur未找到

Jef*_*loo 36 http-status-code-404 angular

我已经按照起始指南进行了扩展,并扩展了之前的角度2版本.我已经更新了我的修订版并相应更改了所有内容.当我运行Web服务器时,我现在收到错误404 for traceur ... 跟踪错误404

这是我的项目结构: 项目结构

相关文件:

index.html的:

    <html>
<head>
    <title>Kinepolis HR-tool</title>

    <base href="./">

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Kinepolis HR tool">
    <meta name="author" content="Jeffrey Devloo!">

    <link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css" />
    <!-- CSS for PrimeUI -->

    <!-- 1. Load libraries -->
    <!-- Polyfill(s) for older browsers -->
    <script src="node_modules/es6-shim/es6-shim.min.js"></script>

    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>

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

<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

systemjs.config.js

(function(global) {

    // map tells the System loader where to look for things
    var map = {
        'app':                        'app', // 'dist',
        'rxjs':                       'node_modules/rxjs',
        'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
        '@angular':                   'node_modules/@angular',
    };

    // packages tells the System loader how to load when no filename and/or no extension
    var packages = {
        'app':                        { main: 'main.js',  defaultExtension: 'js' },
        'rxjs':                       { defaultExtension: 'js' },
        'angular2-in-memory-web-api': { defaultExtension: 'js' },
    };

    var packageNames = [
        '@angular/common',
        '@angular/compiler',
        '@angular/core',
        '@angular/http',
        '@angular/platform-browser',
        '@angular/platform-browser-dynamic',
        '@angular/router',
        '@angular/router-deprecated',
        '@angular/testing',
        '@angular/upgrade',
    ];

    // add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' }
    packageNames.forEach(function(pkgName) {
        packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
    });

    var config = {
        map: map,
        packages: packages
    }

    // filterSystemConfig - index.html's chance to modify config before we register it.
    if (global.filterSystemConfig) { global.filterSystemConfig(config); }

    System.config(config);

})(this);
Run Code Online (Sandbox Code Playgroud)

tsconfig.json

    {
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}
Run Code Online (Sandbox Code Playgroud)

一个可能的问题可能是 在此输入图像描述 这是抵制我的进步.

小智 30

按照Angular Heroes教程我遇到了这个问题.它是由文件中的angular-in-memory-web-api导入的无效位置引起的systemjs.config.js.正确的位置应该是:

'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
Run Code Online (Sandbox Code Playgroud)

并删除packages.angular-in-memory-web-api

请参阅https://github.com/angular/quickstart/commit/541bdc5f634e1142860c56cace247234edfaf74b


Coq*_*cot 23

如果它对任何人都有帮助,我曾经历过这个问题,这是由多行注释引起的(参见Picci的回答这里举例).

  • 哦哇,这太疯狂了!我打破了这个问题已经有两个小时了,多线评论是个问题. (5认同)

Jef*_*loo 22

问题是我的一项服务无效.我已经将构造函数添加为最后一种用于演示目的的方法,但它拒绝加载.

因此,对于那些遇到此错误的人,请打开错误并检查引用的文件是否有错误.问题不在于他没有找到traceur,而是因为他无法加载文件.

  • 这太可恶了:多次出现这个错误,并且总是与"traceur"不同的东西有关.SystemJS有什么问题?难以获得正确的跟踪或调试吗? (10认同)

Jam*_*mes 6

从RC4迁移到RC6时遇到同样的错误.

对于我的项目,我不得不更新systemjs.config.js文件.我停止引用根index.js文件,并开始引用/ bundles中的core.umd.js文件.

接下来:示例