我真的迷失了这个。当我加载Angular2应用程序时,我的服务器有大约200个请求node_modules/systemjs
下的不存在的文件。以下是这些请求的示例:
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Subject.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Observable.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/root.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/toSubscriber.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Subscriber.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/isFunction.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Subscription.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/isArray.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/isObject.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/tryCatch.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/errorObject.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/UnsubscriptionError.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/Observer.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/rxSubscriber.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/observable.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/ObjectUnsubscribedError.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/SubjectSubscription.js.map HTTP/1.1" 404 -
127.0.0.1 - - [13/Sep/2016 13:00:06] "GET /node_modules/systemjs/dist/from.js.map HTTP/1.1" 404 -
我的Angular2应用程序运行正常,我没有收到任何错误,一切都按预期运行。但那些约200个404请求实际上减慢了页面加载速度。出于某种我无法理解的原因,这些404请求甚至没有出现在浏览器的network
标签中,但Wireshark确认他们是从那里来的。
这是我的systemjs.config.js
:
/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
defaultJSExtensions: true,
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',
// angular testing umd bundles
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
'@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js',
'@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
'@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
'moment': 'npm:moment/moment',
'ng2-bs3-modal': 'npm:ng2-bs3-modal',
},
// 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);
答案 0 :(得分:11)
您所看到的是您的浏览器请求source maps,这些文件充当“字典”,在转换之前将转换后的代码(如转换或缩小)转换为其形式。当打开调试器并启用源映射支持时,这通常会在中启动。这是正常行为。如果您关闭调试器并重新加载应用程序,则不会发生源地图请求。
但是,您的应用似乎在错误的位置请求源地图。这些看起来像第三方库在systemjs模块目录中查找它们的源映射。请参阅systemjs文档,了解如何处理路径。
答案 1 :(得分:3)
要完成约瑟夫的回答,您正在加载地图文件。所以你有两个选择:
使用地图文件,您必须生成它们。进入你的tsconfig.json文件。在这里,您可以要求生成地图
不要使用它。因此,您可以在devtools的设置中禁用它们。通常在devtools面板中,顶部栏上有一个齿轮(取决于你的镀铬版本)。在内部设置中,您可以禁用地图使用