Thismoduleprovidessourcemapsupportforstacktracesinnodeviathe[V8stacktraceAPI](https://github.com/v8/v8/wiki/Stack-Trace-API). It uses the [source-map](https://github.com/mozilla/source-map) module to replace the paths and line numbers of source-mapped files with their original paths and line numbers. The output mimics node's stack trace format with the goal of making every compile-to-JS language more of a first-class citizen. Source maps are completely general (not specific to any one language) so you can use source maps with multiple compile-to-JS languages in the same node process.
##InstallationandUsage
####Nodesupport
```
$npminstallsource-map-support
```
Sourcemapscanbegeneratedusinglibrariessuchas[source-map-index-generator](https://github.com/twolfson/source-map-index-generator). Once you have a valid source map, place a source mapping comment somewhere in the file (usually done automatically or with an option by your transpiler):
ThislibraryalsoworksinChrome.WhiletheDevToolsconsolealreadysupportssourcemaps,theV8enginedoesn'tand`Error.prototype.stack` will be incorrect without this library. Everything will just work if you deploy your source files using [browserify](http://browserify.org/). Just make sure to pass the `--debug`flagtothebrowserifycommandsoyoursourcemapsareincludedinthebundledcode.
Thislibraryalsoworksifyouuseanotherbuildprocessorjustincludethesourcefilesdirectly.Inthiscase,includethefile`browser-source-map-support.js` in your page and call `sourceMapSupport.install()`.Itcontainsthewholelibraryalreadybundledforthebrowserusingbrowserify.
ThislibraryalsoworksifyouuseAMD(AsynchronousModuleDefinition),whichisusedintoolslike[RequireJS](http://requirejs.org/). Just list `browser-source-map-support` as a dependency:
Thismoduleinstallstwothings:achangetothe`stack` property on `Error`objectsandahandlerforuncaughtexceptionsthatmimicsnode'sdefaultexceptionhandler(thehandlercanbeseeninthedemosbelow).Youmaywanttodisablethehandlerifyouhaveyourownuncaughtexceptionhandler.Thiscanbedonebypassinganargumenttotheinstaller:
```js
require('source-map-support').install({
handleUncaughtExceptions:false
});
```
Thismoduleloadssourcemapsfromthefilesystembydefault.Youcanprovidealternateloadingbehaviorthroughacallbackasshownbelow.Forexample,[Meteor](https://github.com/meteor) keeps all source maps cached in memory to avoid disk access.
Thereisalsotheoptiontouse`-r source-map-support/register` with typescript, without the need add the `require('source-map-support').install()`inthecodebase:
*LaunchtheHTTPserver(`npm run serve-tests`)andvisit
*http://127.0.0.1:1336/amd-test
*http://127.0.0.1:1336/browser-test
*http://127.0.0.1:1336/browserify-test - **Currently not working** due to a bug with browserify (see [pull request #66](https://github.com/evanw/node-source-map-support/pull/66) for details).
*For`header-test`, run `server.js`insidethatdirectoryandvisithttp://127.0.0.1:1337/