vercel/next.js · error · Error

Failed to parse source map

Error message

Failed to parse source map ${sourceMapFilename}.

What it means

Wrapper in getSourceMapFromFile for the external-map case: reading or JSON.parsing the sibling .map file resolved from sourceMappingURL failed, with the original error as cause. Missing or corrupt external source map files on disk produce this.

Solutions

  1. Ensure the source map file contains valid JSON; regenerate it.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: A referenced source map file fails to parse.

Common situations: An invalid .map file referenced by a compiled asset in dev.

Understand the failure class


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/93fc9fec87046b0e. Report an issue: GitHub.

Appendix: source

Thrown at packages/next/src/server/dev/get-source-map-from-file.ts:82

      return JSON.parse(buffer.toString())
    } catch (error) {
      throw new Error(`Failed to parse source map for ${filename}.`, {
        cause: error,
      })
    }
  }

  const sourceMapFilename = path.resolve(
    path.dirname(filename),
    decodeURIComponent(sourceUrl)
  )

  try {
    const sourceMapContents = await fs.readFile(sourceMapFilename, 'utf-8')

    return JSON.parse(sourceMapContents.toString())
  } catch (error) {
    throw new Error(`Failed to parse source map ${sourceMapFilename}.`, {
      cause: error,
    })
  }
}

View on GitHub (pinned to 0eb3775416)