node - how to use source-map with nyc and mocha node - how to use source-map with nyc and mocha node.js node.js

node - how to use source-map with nyc and mocha


the basic pre-condition for it to work would be (as described here):

npm install --save-dev source-map-support

make sure nyc is ^10.3.2 (10.3.0 was broken).

"devDependencies": {    ...    "mocha": "^3.3.0",    "nyc": "^10.3.2",    "source-map-support": "^0.4.15",}

the nyc config should be "sourceMap": true, "produce-source-map": true.

and the documentation explains how to use them:

CLI Usage

node -r source-map-support/register compiled.js

Programmatic Usage

Put the following line at the top of the compiled file.

require('source-map-support').install();

one can also define mapping file-names by adding comments:

//# sourceMappingURL=filename.js.map