Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

@jridgewell/trace-mapping

Find the real line behind an error.

Dev workflow and configNPM

GitHubWebsite

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/LICENSE

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

56 / 100
Gid Score, #1336 overall
389M
downloads a week, npm
61
GitHub stars
16
agent projects use it
@jridgewell/trace-mapping: downloads per weeknpm, @jridgewell/trace-mapping 388,559,429
@jridgewell/trace-mapping: GitHub starsjridgewell/sourcemaps 61

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

10 projects, 0.4%
8 projects, 0.2%
5 projects, 0.2%

Often used with

In 96.6% of its projects
In 94.9% of its projects
In 94.9% of its projects
In 94.9% of its projects
In 94.9% of its projects
In 94.9% of its projects
In 94.9% of its projects
In 93.2% of its projects

More about @jridgewell/trace-mapping

More in Dev workflow and config

Alternatives

@jridgewell/trace-mapping This page

MITGid 56389M/wk

source-map-support

Pick source-map-support when you only want Node.js to print stack traces with original file names automatically.

Compare @jridgewell/trace-mapping with another tool

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.”

  1. Add the package to your project.

    npm install @jridgewell/trace-mapping

    From github.com/jridgewell/sourcemaps/blob/main/packages/trace-mapping/README.md

  2. 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

  3. 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

originalPositionFor(tracer, { line: 1, column: 91 }) with the column copied from a stack trace
Pass column: stackColumn - 1; lines stay as they are

The library counts columns from 0, stack traces from 1; our run needed column 90 for "bundle.min.js:1:91".

traceSegment(tracer, 1, 5) with the same 1-based line you give originalPositionFor
traceSegment(tracer, 0, 5); traceSegment takes 0-based lines

The low-level call counts lines from 0, unlike originalPositionFor.

new SourceMapConsumer(map) and consumer.originalPositionFor({...}) from the source-map package
const tracer = new TraceMap(map); originalPositionFor(tracer, {...}) as plain imported functions

The lookups have the same names but are separate functions that take the TraceMap first.

Printing pos.source and pos.line without checking them
if (pos.source === null) keep the original frame; only rewrite frames that traced

A spot with no mapping returns source, line, column and name all null; our run got that for a column before the first mapping.

new TraceMap(sectionedMap) for a map that has a sections field
new AnyMap(sectionedMap) (also exported as FlattenMap in 0.3.31)

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.