错误 'jquery-2.0.2.min.map 未找到'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18487596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 21:45:30  来源:igfitidea点击:

Error 'jquery-2.0.2.min.map not found'

jquerygoogle-chrome-devtools

提问by Anton Belev

I'm getting this error in Google Chrome developer tools:

我在 Google Chrome 开发人员工具中收到此错误:

jquery-2.0.2.min.map not found

找不到 jquery-2.0.2.min.map

I found a way to get rid of it by removing this line from my jquery-2.0.2.min.js:

我找到了一种方法来摆脱它,从我的jquery-2.0.2.min.js

//@ sourceMappingURL=jquery-2.0.2.min.map

However, I don't believe this was a good idea, since this may be just a temporary fix that may be a problem in the future. Since I don't really understand the nature of this error and the goofy solution: what's causing this error and is there a better fix for it?

但是,我认为这不是一个好主意,因为这可能只是一个临时修复,将来可能会成为问题。因为我不太了解这个错误的本质和愚蠢的解决方案:是什么导致了这个错误,是否有更好的解决方法?

Apparently, this is not a question related to jQuery2.0.2 only. A very similar Stack Overflow question with a great explanation is jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found). I hope this will shed some light on the situation.

显然,这不仅仅是与jQuery2.0.2相关的问题。一个非常相似的堆栈溢出问题有一个很好的解释是jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found)。我希望这能说明情况。

回答by kayz1

1. Downloadthe map file and uncompressed version of jquery. Put them with minified version.JavaScript

1、下载地图文件和jquery解压版。把它们放在缩小版中。JavaScript

2. Include minified version into your HTMLHTML

2. 在你的 HTML 中包含缩小版本HTML

3. Check in ChromeChrome

3. 签入 Chrome铬合金

4. Read Introduction to JavaScript Source Maps

4. 阅读JavaScript Source Maps 简介

5. Get familiar with Debugging JavaScript

5. 熟悉调试 JavaScript

回答by Rob Schmuecker

You should have a file included in your download of jquery-2.0.2 called jquery-2.0.2.min.mapmake sure it is in the same location as jquery-2.0.2.min.jsand you should be good to go.

您应该在下载的 jquery-2.0.2 中包含一个名为的文件,请jquery-2.0.2.min.map确保它与该文件位于同一位置jquery-2.0.2.min.js,这样您就可以开始使用了。

If you don't have a copy you can download it here: http://code.jquery.com/jquery-2.0.2.min.map

如果您没有副本,可以在此处下载:http: //code.jquery.com/jquery-2.0.2.min.map

Some more background about this from the jQuery website.

来自jQuery 网站的更多背景信息。

Starting with jQuery 1.9, we also make available sourcemap files that can be used to debug the compressed file in sourcemap-aware browsers such as Google Chrome. The map file is not required for users to run jQuery, it just improves the developer's debugger experience.

从 jQuery 1.9 开始,我们还提供了源映射文件,可用于在支持源映射的浏览器(如 Google Chrome)中调试压缩文件。用户运行 jQuery 不需要映射文件,它只是改善了开发人员的调试器体验。

回答by gotqn

As it is announced in jQuery 1.11.0/2.1.0 Beta 2 Releasedthe source map comment will be removed so the issue will not appear in newer versions of jQuery.

正如在jQuery 1.11.0/2.1.0 Beta 2 Released源地图中宣布的那样,注释将被删除,因此该问题不会出现在jQuery.

Anyway, if you need to use a source map, it still be available:

无论如何,如果您需要使用源映射,它仍然可用:

We'll still be generating and distributing sourcemaps, but you will need to add the appropriate sourcemap comment at the end of the minified file if the browser does not support manually associating map files (currently, none do). If you generate your own jQuery file using the custom build process, the sourcemap comment will be present in the minified file and the map is generated; you can either leave it in and use sourcemaps or edit it out and ignore the map file entirely.

我们仍然会生成和分发源映射,但是如果浏览器不支持手动关联映射文件(目前,不支持),您将需要在缩小文件的末尾添加适当的源映射注释。如果您使用自定义构建过程生成自己的 jQuery 文件,则源映射注释将出现在缩小的文件中并生成映射;您可以保留它并使用源映射,也可以将其编辑掉并完全忽略映射文件。

Hereyou find more details about the changes.

您可以在此处找到有关更改的更多详细信息。

回答by SharpCoder

You can remove the 404 by removing the line

您可以通过删除该行来删除 404

//@ sourceMappingURL=jquery-2.1.2.min.map

from the top part of your jQuery file.

从 jQuery 文件的顶部。

Purpose of a source map

源映射的目的

Basically it's a way to map a combined/minified file back to an unbuilt state. When you build for production, along with minifying and combining your JavaScript files, you generate a source map which holds information about your original files. When you query a certain line and column number in your generated JavaScript you can do a lookup in the source map which returns the original location.

基本上,这是一种将组合/缩小文件映射回未构建状态的方法。当您为生产构建时,连同缩小和组合您的 JavaScript 文件,您会生成一个源映射,其中包含有关原始文件的信息。当您在生成的 JavaScript 中查询某个行号和列号时,您可以在返回原始位置的源地图中进行查找。