Registry / serialization / source-map-support

source-map-support

JSON →
library0.5.21jsnpmunverified

Provides source map support for stack traces in Node.js and browsers via the V8 stack trace API. Current stable version: 0.5.21. Uses the Mozilla source-map module to replace paths and line numbers of source-mapped files with originals. Key differentiator: works with any compile-to-JS language, supports both CLI (-r) and programmatic usage, and includes browser support via bundled script. Maintained by Evan Wallace, releases are infrequent but stable.

npm install source-map-support
INSTALL
IMPORT
SIG · SOURCE-MAP-SUPPORT
S
source-map-support
serializationjavascriptv0.5.21
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sourceMapSupport
import sourceMapSupport from 'source-map-support'
const sourceMapSupport = require('source-map-support').default
Default export is the module itself; .default not needed in CommonJS
install
require('source-map-support').install()
const install = require('source-map-support/install')
install is a method on the default export, not a separate module
register
import 'source-map-support/register'
require('source-map-support/register') in ESM
The register module is a side-effect import; ESM import is preferred for modern Node

Shows CommonJS and ESM installation, CLI usage, options, and browser setup for source map support.

// Install: npm install source-map-support // In your compiled file: require('source-map-support').install(); // Or via CLI: // node -r source-map-support/register compiled.js // Example with options: require('source-map-support').install({ handleUncaughtExceptions: false, environment: 'node' }); // Browser usage: // <script src="browser-source-map-support.js"></script> // <script>sourceMapSupport.install();</script> // For TypeScript (ESM): import sourceMapSupport from 'source-map-support'; sourceMapSupport.install();
Debug
Known issues
breakingCannot read property 'name' of undefined
fix
Upgrade to >=0.5.16
affects: <0.5.16
gotchaModule does not support source maps in stack traces when errors are thrown before install() is called
fix
Call install() at the very top of your entry file, before any other code
affects: all
gotchaOnly works with V8 engine (Node.js, Chrome) - not with other JavaScript engines
fix
Not applicable; this is a design limitation
affects: all
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'name')
Bug in version <0.5.16 when a stack frame lacks function name
fix
Update source-map-support to >=0.5.16
ReferenceError: window is not defined
Trying to use browser-source-map-support.js in Node.js environment
fix
Use the Node-specific module (require('source-map-support')) instead of browser version
Error: source-map-support/register must be required before any other modules
The register module was required after other code has executed
fix
Add --require source-map-support/register as the first CLI argument or require it at the very top of the entry file
Upgrade
Version history
0.5.21latest on npm
Audit
Dependencies
source-maprequiredCore dependency for parsing and manipulating source maps
buffer-fromoptionalUsed for creating buffers in older Node versions
Agent activity
16 hits · last 30 days
node
12
OpenAI (training)
2
Amazon
1
Resources
source-map-support — npm install source-map-support · libregistry