Skip to content

Commit e3bef40

Browse files
author
Mike Atkins
committed
Add note about -r when using with node
This resolves #113
1 parent 0e3c066 commit e3bef40

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@ This module provides source map support for stack traces in node via the [V8 sta
1111
$ npm install source-map-support
1212
```
1313

14-
Source maps can be generated using libraries such as [source-map-index-generator](https://github.com/twolfson/source-map-index-generator). Once you have a valid source map, insert the following line at the top of your compiled code:
15-
16-
```js
17-
require('source-map-support').install();
18-
```
19-
20-
And place a source mapping comment somewhere in the file (usually done automatically or with an option by your transpiler):
14+
Source maps can be generated using libraries such as [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):
2115

2216
```
2317
//# sourceMappingURL=path/to/source.map
@@ -27,6 +21,24 @@ If multiple sourceMappingURL comments exist in one file, the last sourceMappingU
2721
respected (e.g. if a file mentions the comment in code, or went through multiple transpilers).
2822
The path should either be absolute or relative to the compiled file.
2923

24+
From here you have two options.
25+
26+
##### Node >= 2.2.0
27+
28+
Node 2.2.0 added the `-r` command line argument, so if you're using 2.2.0 or greater, you can use the following to run your code.
29+
30+
```bash
31+
node -r source-map-support/register compiled.js
32+
```
33+
34+
##### Node < 2.2.0
35+
36+
Put the following line at the top of the compiled file.
37+
38+
```js
39+
require('source-map-support').install();
40+
```
41+
3042
It is also possible to install the source map support directly by
3143
requiring the `register` module which can be handy with ES6:
3244

0 commit comments

Comments
 (0)