@jridgewell/trace-mapping
Find the real line behind an error.
1. License
“Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction”
MIT allows use in paid and closed-source apps.
github.com/jridgewell/sourcemaps/blob/main/packages/trace-mapping/LICENSE2. Maintained
github.com/jridgewell/sourcemaps3. Used by agents' projects
Dependency in 16 public GitHub projects set up for AI coding agents that we scanned (0.3%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error
What @jridgewell/trace-mapping does
@jridgewell/trace-mapping is a small free JavaScript library for source maps. When an error points to line 1, column 91 of a squeezed one-line file, it tells you the file, line and column in the code you actually wrote. Error reports and developer tools use it to show readable locations.
What people build with it
Readable errors from live sites
Visitors hit an error in your shipped, squeezed code. Your error log turns "bundle.min.js:1:91" into "src/cart.js line 8" before you read it.
Show the code next to an error
An internal error page or a bug report shows the few lines of original code around the failing line, read from the source map itself.
Jump from source to shipped code
A tool knows a line in your source file and needs the matching spot in the built file, for example to place a marker or a breakpoint.
Hide library code in stack traces
Your error view greys out frames that come from third-party packages, so the lines from your own code stand out.
Swap out a heavier source map reader
A build or test tool that used the older source-map package keeps the same lookups without loading WebAssembly.
@jridgewell/trace-mapping popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How @jridgewell/trace-mapping is used
- @jridgewell/trace-mapping is a dependency in 16 of the 6,258 public GitHub projects set up for AI coding agents that we scanned, too few to describe it from them alone. Our scan also samples projects by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750); counting those, it appears in 59 projects, and what it is used with below comes from all of them.
- Projects that use it most often also use Vite (96.6%), Radix UI (94.9%), Class Variance Authority (94.9%).
By coding agent
Often used with
More about @jridgewell/trace-mapping
More in Dev workflow and config
Alternatives
@jridgewell/trace-mapping This page
Pick source-map-support when you only want Node.js to print stack traces with original file names automatically.
Get started
Tell your AI assistant
“Use @jridgewell/trace-mapping (pin 0.3.31) to turn the file:line:column positions in our error stack traces into original source positions with originalPositionFor; subtract 1 from stack trace columns, and handle a null source when there is no mapping.”
Add the package to your project.
npm install @jridgewell/trace-mappingFrom github.com/jridgewell/sourcemaps/blob/main/packages/trace-mapping/README.md
Load a source map into a TraceMap and ask for the original spot of a line and column.
import { TraceMap, originalPositionFor } from '@jridgewell/trace-mapping'; const tracer = new TraceMap(map); // Lines start at line 1, columns at column 0. const traced = originalPositionFor(tracer, { line: 1, column: 5 });From github.com/jridgewell/sourcemaps/blob/main/packages/trace-mapping/README.md
For maps glued from several parts (a rare "sections" format), load them with AnyMap instead.
import { AnyMap } from '@jridgewell/trace-mapping';From github.com/jridgewell/sourcemaps/blob/main/packages/trace-mapping/README.md
Mistakes to avoid
The library counts columns from 0, stack traces from 1; our run needed column 90 for "bundle.min.js:1:91".
The low-level call counts lines from 0, unlike originalPositionFor.
The lookups have the same names but are separate functions that take the TraceMap first.
A spot with no mapping returns source, line, column and name all null; our run got that for a column before the first mapping.
Sectioned maps need the AnyMap helper, which returns a normal TraceMap.
Questions
Does it need WebAssembly?
No. It offers the same lookups as the older source-map package without WebAssembly.
Why do I get an error about line 0?
Lines start at 1. In our run, line 0 threw "line must be greater than 0 (lines start at line 1)".
Can it show the original code, not only the line number?
Yes, when the map includes the source text; sourceContentFor returns it.
Can I use it in a paid product?
Yes. It is MIT; keep the notice with copies of the code.