1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
---
title: Source map errors
slug: Tools/Debugger/Source_map_errors
tags:
- Depurador
- Depuração
- Ferramentas
- Ferramentas de Desenvolvimento
- Referencia
- Source maps
translation_of: Tools/Debugger/Source_map_errors
---
<div>{{ToolsSidebar}}</div>
<p class="summary"><em>Source maps</em> 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 <em>source maps</em>. Esta página explica os problemas mais comuns e como os corrigir.</p>
<div class="note">
<p><strong>Nota</strong>: se é novo para <em>source maps</em>, pode saber mais sobre os mesmo em <a href="/pt-PT/docs/Tools/Debugger/How_to/Use_a_source_map">How to use a source map</a>.</p>
</div>
<h2 id="Reportar_Source_map_error_geral">Reportar "Source map error" geral</h2>
<p>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:</p>
<p><img alt="Error from invalid JSON" src="https://mdn.mozillademos.org/files/15423/invalid-json.png" style="border-style: solid; border-width: 1px; display: block; height: 57px; margin: 0px auto; width: 744px;"></p>
<p>Here, the resource URL tells us that <code>bundle.js</code> 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.</p>
<p>There are a few common ways that source maps can go wrong; they are detailed in the following sections.</p>
<h2 id="Source_map_está_em_falta_ou_inacessível">"Source map" está em falta ou inacessível</h2>
<p>O recurso <em>source map</em> pode estar em falta ou inacessível.</p>
<p><img alt="Source map file is missing" src="https://mdn.mozillademos.org/files/15429/missing-map.png" style="border-style: solid; border-width: 1px; display: block; height: 42px; margin: 0px auto; width: 733px;"></p>
<p>The fix here is to make sure the file is being served and is accessible to the browser</p>
<h2 id="Source_map_inválido">"Source map" inválido</h2>
<p>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:</p>
<ul>
<li><code>SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data</code></li>
<li><code>Error: "version" is a required argument</code></li>
</ul>
<p><img alt='Error: "version" is a required argument' src="https://mdn.mozillademos.org/files/15425/missing-field.png" style="border-style: solid; border-width: 1px; display: block; height: 45px; margin: 0px auto; width: 743px;"></p>
<h2 id="Source_original_está_em_falta">"Source" original está em falta</h2>
<p>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:</p>
<p><img alt="Debugger source tab showing the error" src="https://mdn.mozillademos.org/files/15421/Screenshot%20from%202017-09-15%2014-32-02.png" style="border-style: solid; border-width: 1px; display: block; height: 35px; margin: 0px auto; width: 727px;"></p>
<p>In this case, the error will also be displayed in the source tab in the debugger:</p>
<p><img alt="Debugger source tab showing the error" src="https://mdn.mozillademos.org/files/15427/debugger-tab.png" style="border-style: solid; border-width: 1px; display: block; height: 109px; margin: 0px auto; width: 616px;"></p>
<h2 id="NetworkError_quando_tenta_obter_o_recurso">"NetworkError" quando tenta obter o recurso</h2>
<p>A bug in Firefox prevents it from loading source maps for web extensions.</p>
<p>See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1437937">Bug 1437937: WebExtensions Doesn't Find Source Maps</a> for details.</p>
<pre class="syntaxbox"><span class="message-body-wrapper"><span class="message-flex-body"><span class="devtools-monospace message-body">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</span></span></span></pre>
<p>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.</p>
|