How to use source maps in node js?
You can use https://www.npmjs.com/package/source-map-support
$ npm install source-map-support --save-dev
Then change your run command in package.json to:
node -r source-map-support/register index.js
(Note that you should have an index.map.js next to index.js)
In Node v12.12.0+ sourcemaps are supported natively. Pass --enable-source-maps
flag to enable them.
One caveat in Node v12.12.0
is that Error.prepareStackTrace
will no longer be called when source maps are enabled. This was fixed in v12.16+
.