简体   繁体   中英

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. Why has chrome decided there should be a source map in this case and how can I prevent it from doing so?

Source maps are indicated by having a special comment at the end of the file, as described at MDN :

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

So there is likely a line like this in your index.js file:

//# 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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