{"id":26418,"library":"source-map-support","title":"source-map-support","description":"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.","status":"active","version":"0.5.21","language":"javascript","source_language":"en","source_url":"https://github.com/evanw/node-source-map-support","tags":["javascript"],"install":[{"cmd":"npm install source-map-support","lang":"bash","label":"npm"},{"cmd":"yarn add source-map-support","lang":"bash","label":"yarn"},{"cmd":"pnpm add source-map-support","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for parsing and manipulating source maps","package":"source-map","optional":false},{"reason":"Used for creating buffers in older Node versions","package":"buffer-from","optional":true}],"imports":[{"note":"Default export is the module itself; .default not needed in CommonJS","wrong":"const sourceMapSupport = require('source-map-support').default","symbol":"sourceMapSupport","correct":"import sourceMapSupport from 'source-map-support'"},{"note":"install is a method on the default export, not a separate module","wrong":"const install = require('source-map-support/install')","symbol":"install","correct":"require('source-map-support').install()"},{"note":"The register module is a side-effect import; ESM import is preferred for modern Node","wrong":"require('source-map-support/register') in ESM","symbol":"register","correct":"import 'source-map-support/register'"}],"quickstart":{"code":"// Install: npm install source-map-support\n\n// In your compiled file:\nrequire('source-map-support').install();\n\n// Or via CLI:\n// node -r source-map-support/register compiled.js\n\n// Example with options:\nrequire('source-map-support').install({\n  handleUncaughtExceptions: false,\n  environment: 'node'\n});\n\n// Browser usage:\n// <script src=\"browser-source-map-support.js\"></script>\n// <script>sourceMapSupport.install();</script>\n\n// For TypeScript (ESM):\nimport sourceMapSupport from 'source-map-support';\nsourceMapSupport.install();","lang":"javascript","description":"Shows CommonJS and ESM installation, CLI usage, options, and browser setup for source map support."},"warnings":[{"fix":"Upgrade to >=0.5.16","message":"Cannot read property 'name' of undefined","severity":"breaking","affected_versions":"<0.5.16"},{"fix":"Call install() at the very top of your entry file, before any other code","message":"Module does not support source maps in stack traces when errors are thrown before install() is called","severity":"gotcha","affected_versions":"all"},{"fix":"Not applicable; this is a design limitation","message":"Only works with V8 engine (Node.js, Chrome) - not with other JavaScript engines","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Update source-map-support to >=0.5.16","cause":"Bug in version <0.5.16 when a stack frame lacks function name","error":"TypeError: Cannot read properties of undefined (reading 'name')"},{"fix":"Use the Node-specific module (require('source-map-support')) instead of browser version","cause":"Trying to use browser-source-map-support.js in Node.js environment","error":"ReferenceError: window is not defined"},{"fix":"Add --require source-map-support/register as the first CLI argument or require it at the very top of the entry file","cause":"The register module was required after other code has executed","error":"Error: source-map-support/register must be required before any other modules"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}