简体   繁体   English

是什么提示 chrome devtools 寻找源图

[英]What prompts chrome devtools to look for source maps

I am getting warnings like DevTools failed to load SourceMap: Could not parse content for http://localhost:8000/index.js.map: Unexpected token < in JSON at position 0 where chrome is trying to a fetch a source map that doesn't exist.我收到类似DevTools failed to load SourceMap: Could not parse content for http://localhost:8000/index.js.map: Unexpected token < in JSON at position 0警告DevTools failed to load SourceMap: Could not parse content for http://localhost:8000/index.js.map: Unexpected token < in JSON at position 0 where chrome is试图获取一个没有的源映射不存在。 Why has chrome decided there should be a source map in this case and how can I prevent it from doing so?为什么 chrome 决定在这种情况下应该有一个源映射,我该如何防止它这样做?

Source maps are indicated by having a special comment at the end of the file, as described at MDN :源映射由文件末尾的特殊注释表示,如MDN 所述

//# sourceMappingURL=http://example.com/path/to/your/sourcemap.map

So there is likely a line like this in your index.js file:所以在你的 index.js 文件中可能有这样一行:

//# sourceMappingURL=index.js.map

You will need to remove this line (I imagine this may consist of disabling source map generation in your build process) if you would like to get rid of the error for your particular assets.如果您想消除特定资产的错误,您将需要删除此行(我想这可能包括在构建过程中禁用源映射生成)。 If you want to disable source maps in general, you can do the following, quoted from another post :如果您想在一般情况下禁用源映射,您可以执行以下操作, 引用自另一篇文章

Open Developer Tools, go to "Settings" for Developer Tools, then uncheck Enable JavaScript Sourcemaps under the "Sources" settings.打开开发人员工具,转到开发人员工具的“设置”,然后取消选中“源”设置下的启用 JavaScript 源映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM