gpt4 book ai didi

javascript - SystemJS 对不存在的文件发出约 200 个请求

转载 作者:可可西里 更新时间:2023-11-01 01:18:33 26 4
gpt4 key购买 nike

我真的很迷茫。当我加载我的 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);

最佳答案

您看到的是您的浏览器请求 source maps ,充当“字典”的文件,将转换后的代码(如转译或缩小)转换为转换前的形式。当您打开调试器并启用源映射支持时,这通常会启动。。这是正常行为。如果您关闭调试器并重新加载您的应用程序,源映射请求将不会发生。

但是,您的应用似乎在错误的位置请求源 map 。那些看起来像第三方库在 systemjs 模块目录中寻找它们的源映射。请参阅有关如何处理路径的 systemjs 文档。

关于javascript - SystemJS 对不存在的文件发出约 200 个请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39469701/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com