Source map errors

This translation is incomplete. Please help translate this article from English

Source maps são ficheiros JSON que fornecem um modo para associar as fontes transformadas, como visto pelo navegador, com as suas fontes originais, conforme escrito pelo programador. Às vezes, pode encontrar problemas ao trabalhar com source maps. Esta página explica os problemas mais comuns e como os corrigir.

Nota: se é novo para source maps, pode saber mais sobre os mesmo em How to use a source map.

Reportar "Source map error" geral

If you do see a problem, a message will appear in the webconsole. This message will show an error message, the resource URL, and the source map URL:

Error from invalid JSON

Here, the resource URL tells us that bundle.js mentions a source map, and the source map URL tells us where to find the source map data (in this case, relative to the resource).  The error tells us that the source map is not JSON data — so we're serving the wrong file.

There are a few common ways that source maps can go wrong; they are detailed in the following sections.

"Source map" está em falta ou inacessível

O recurso source map pode estar em falta ou inacessível.

Source map file is missing

The fix here is to make sure the file is being served and is accessible to the browser

"Source map" inválido

The source map data can be invalid — either simply not a JSON file at all, or with an incorrect structure. Typical error messages here are:

  • SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
  • Error: "version" is a required argument

Error: "version" is a required argument

"Source" original está em falta

An original source may be missing.  You may encounter this when trying to open one of the original sources in the debugger. The message looks a little different in this case:

Debugger source tab showing the error

In this case, the error will also be displayed in the source tab in the debugger:

Debugger source tab showing the error

"NetworkError" quando tenta obter o recurso

A bug in Firefox prevents it from loading source maps for web extensions.

See Bug 1437937: WebExtensions Doesn't Find Source Maps for details.

Source-Map-Fehler: TypeError: NetworkError when attempting to fetch resource.
 Ressourcen-Adresse: moz-extension://c7f0f003-4fcf-49fd-8ec0-c49361266581/background.js
 Source-Map-Adresse: background.js.map

The only workaround is to manually change the map URL to a public one (http://localhost:1234/file.map.js) and start a local webserver at this port.