jQuery 的 jquery-1.10.2.min.map 正在触发 404(未找到)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18365315/
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:26:33  来源:igfitidea点击:

jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found)

javascriptjquerygoogle-chrome-devtools

提问by Paul Irish

I'm seeing error messages about a file, min.map, being not found:

我看到有关min.map未找到文件的错误消息:

GET jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found)

GET jQuery 的 jquery-1.10.2.min.map 正在触发 404(未找到)



Screenshot

截屏

enter image description here

在此处输入图片说明

Where is this coming from?

这是从哪里来的?

回答by Paul Irish

If Chrome DevTools is reporting a 404 for a .map file (maybe jquery-1.10.2.min.map, jquery.min.mapor jquery-2.0.3.min.map, but can happen with anything) first thing to know is this is only requested when using the DevTools. Your users will not be hitting this 404.

如果 Chrome DevTools 报告 .map 文件的 404(可能jquery-1.10.2.min.mapjquery.min.mapjquery-2.0.3.min.map,但可能发生在任何事情上)首先要知道的是,这仅在使用 DevTools 时请求。 您的用户不会遇到此 404。

Now you can fix this or disable the sourcemap functionality.

现在您可以修复此问题或禁用源映射功能。

Fix: get the files

修复:获取文件

Next, it's an easy fix. Head to http://jquery.com/download/and click the Download the map filelink for your version, and you'll want the uncompressed file downloaded as well.

接下来,这是一个简单的修复。前往http://jquery.com/download/并单击下载适用于您的版本的地图文件链接,您还需要下载未压缩的文件。

enter image description here

在此处输入图片说明

Having the map file in place allows you do debug your minified jQuery via the original sources, which will save a lot of time and frustration if you don't like dealing with variable names like aand c.

有了地图文件,您就可以通过原始源调试缩小的 jQuery,如果您不喜欢处理ac.

More about sourcemaps here: An Introduction to JavaScript Source Maps

更多关于源映射的信息JavaScript 源映射简介

Dodge: disable sourcemaps

道奇:禁用源图

Instead of getting the files, you can alternatively disable JavaScript source maps completely for now, in your settings. This is a fine choice if you never plan on debugging JavaScript on this page. Use the cog icon in the bottom right of the DevTools, to open settings, then: enter image description here

您可以暂时在设置中完全禁用 JavaScript 源映射,而不是获取文件。如果您从不打算在此页面上调试 JavaScript,这是一个不错的选择。使用 DevTools 右下角的齿轮图标打开设置,然后: 在此处输入图片说明

回答by kiranvj

You can remove the 404 by removing the line

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

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

from the top part of your jQuery file.

从 jQuery 文件的顶部。

The top part of the jQuery file will look like this.

jQuery 文件的顶部将如下所示。

/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
//@ sourceMappingURL=jquery-1.10.2.min.map
*/

Just change that to

只需将其更改为

/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license */

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. Developer tools (currently WebKit nightly builds, Google Chrome, or Firefox 23+) can parse the source map automatically and make it appear as though you're running unminified and uncombined files. (Read more on this here)

基本上,这是一种将组合/缩小文件映射回未构建状态的方法。当您为生产构建时,连同缩小和组合您的 JavaScript 文件,您会生成一个源映射,其中包含有关原始文件的信息。当您在生成的 JavaScript 中查询某个行号和列号时,您可以在返回原始位置的源地图中进行查找。开发人员工具(目前是 WebKit nightly builds、Google Chrome 或 Firefox 23+)可以自动解析源映射并使它看起来好像您正在运行未缩小和未组合的文件。(在此处阅读更多相关信息

回答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.

Here is the official announcement:

以下是官方公告:

One of the changes we've made in this beta is to remove the sourcemap comment. Sourcemaps have proven to be a very problematic and puzzling thing to developers, generating scores of confused questions on forums like StackOverflow and causing users to think jQuery itself was broken.

我们在此测试版中所做的更改之一是删除源映射注释。事实证明,Sourcemaps 对开发人员来说是一个非常有问题和令人费解的事情,在 StackOverflow 等论坛上产生了大量令人困惑的问题,并导致用户认为 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 can find more details about the changes.

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



Hereyou can find confirmation that with the jQuery 1.11.0/2.1.0 Releasedthe source-map comment in the minified file is removed.

在这里,您可以找到确认jQuery 1.11.0/2.1.0 Released已删除缩小文件中的 source-map 注释。

回答by kayz1

  1. Downloadthe map file and the uncompressed version of jQuery.
    Put them with the minified version:

    JavaScript

  2. Include minified version into your HTML:

    HTML

  3. Check in Google Chrome:

    Google Chrome

  4. Read Introduction to JavaScript Source Maps

  5. Get familiar with Debugging JavaScript

  1. 下载地图文件和未压缩版本的jQuery
    把它们放在缩小版本中:

    JavaScript

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

    HTML

  3. 签入谷歌浏览器:

    谷歌浏览器

  4. 阅读JavaScript Source Maps 简介

  5. 熟悉调试 JavaScript

回答by Andres Separ

The new versions of jQuery require this file http://code.jquery.com/jquery-1.10.2.min.map

新版本的 jQuery 需要这个文件http://code.jquery.com/jquery-1.10.2.min.map

The usability of this file is described here http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/

此文件的可用性在此处描述http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/

Update:

更新:

jQuery 1.11.0/2.1.0

jQuery 1.11.0/2.1.0

// sourceMappingURL comment is not included in the compressed file.

// sourceMappingURL 注释不包含在压缩文件中

回答by James J. Ye

As I understand the browser, Chrome at least, it doesn't disable the source mapping by default. That means your application's users will trigger this source-mapping request by default.

据我了解,浏览器至少是 Chrome,默认情况下它不会禁用源映射。这意味着您的应用程序的用户将默认触发此源映射请求。

You can remove the source mapping by deleting the //@ sourceMappingURL=jquery.min.mapfrom your JavaScript file.

您可以通过//@ sourceMappingURL=jquery.min.map从 JavaScript 文件中删除 来删除源映射。

回答by Andriyun

If you want to get source map file different version, you can use this link http://code.jquery.com/jquery-x.xx.x.min.map

如果你想获得不同版本的源地图文件,你可以使用这个链接 http://code.jquery.com/jquery-x.xx.x.min.map

Instead x.xx.x put your version number.

而是 x.xx.x 输入您的版本号。

Note: Some links, which you get on this method, may be broken :)

注意:您通过此方法获得的某些链接可能已损坏:)

回答by drobison

After following the instructions in the other answers, I needed to strip the version from the map file for this to work for me.

按照其他答案中的说明进行操作后,我需要从地图文件中删除该版本以使其对我有用。

Example: Rename

示例:重命名

jquery-1.9.1.min.map

jquery-1.9.1.min.map

to

jquery.min.map

jquery.min.map

回答by nickspiel

I was presented with the same issue. The cause for me was Gruntconcatenating my JavaScript file.

我遇到了同样的问题。我的原因是Grunt连接了我的 JavaScript 文件。

I was using a ;\nas a separator which caused the path to the source map to 404.

我使用 a;\n作为分隔符,导致源映射的路径为 404。

So dev tools was looking for jquery.min.map;instead of jquery.min.map.

所以开发工具正在寻找jquery.min.map;而不是jquery.min.map.

I know that isn't the answer to the original question, but I am sure there are others out there with a similar Grunt configuration.

我知道这不是原始问题的答案,但我确信还有其他人具有类似的 Grunt 配置。

回答by user3235672

jQuery 1.11.0/2.1.0 the // sourceMappingURL comment is not included in the compressed file.

jQuery 1.11.0/2.1.0 // sourceMappingURL 注释不包含在压缩文件中。