加载main.js时出现Angular2 XHR错误(404 Not Found)

时间:2017-03-08 19:31:33

标签: node.js angular

我使用gulp来观看打字稿文件,并将翻译好的public static string ScientificNotationTimespan(int milliseconds) { var timeSpan = new TimeSpan(0, 0, 0, 0, milliseconds); var totalDays = timeSpan.TotalDays; if (totalDays < 7) { if (timeSpan.TotalDays > 1) return timeSpan.TotalDays.ToString() + " days"; if (timeSpan.TotalHours > 1) return timeSpan.TotalHours.ToString() + " hours"; if (timeSpan.TotalMinutes > 1) return timeSpan.TotalMinutes.ToString() + " minutes"; if (timeSpan.TotalSeconds > 1) return timeSpan.TotalSeconds.ToString() + " seconds"; return milliseconds.ToString() + "milliseconds"; } var weeks = totalDays / 7; //How long is a month? 28, 29, 30 or 31 days? var years = totalDays / 365; if (years < 1) return weeks.ToString() + " weeks"; var decades = years / 10; if (decades < 1) return years.ToString() + " years"; var centuries = decades / 10; if (centuries < 1) return decades.ToString() + " decades"; var millenia = centuries / 10; if (millenia < 1) return centuries.ToString() + " centuries"; return millenia.ToString() + " millenia"; } 文件存储在.js中。每当我启动我的项目时,angular2都不起作用,因为这个错误:

  

无法获得main.js

Here is the Error that I'm getting.

system.config.js

public/js

index.ejs

(我使用快递,下面的所有文件都已正确加载)。

(function (global) {
System.config({
paths: {
  'npm:': 'node_modules/'
},
map: {
 app: 'public/js',

  '@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',

  'rxjs':                      'npm:rxjs',
  'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
},
packages: {
  app: {
    main: './main',
    defaultExtension: 'js'
  },
  rxjs: {
    defaultExtension: 'js'
  }
}
});
})(this);

main.js

<head>
  <title>Chat room</title>
  <link rel="stylesheet" href="/css/index.css">

  <script src="/systemjslib/system.src.js"></script>
  <script src="/systemjsconf"></script>
  <script src="/shimlib/shim.min.js"></script>
  <script src="/zonelib/zone.js"></script>
  <script src="/rxjslib/Reflect.js"></script>
</head>
<body>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
  <my-app>Loading AppComponent content here ...</my-app>
</body>

Project files structure

我真的很感激一些帮助。提前致谢。如果我错过了一些重要的文件,请告诉我我将编辑这篇文章,我真的需要修复它。

0 个答案:

没有答案