nodexh

a wrapper around the `node` executable for better stacktraces with sourcemaps, sourcecode excerpts

Usage no npm install needed!

<script type="module">
  import nodexh from 'https://cdn.skypack.dev/nodexh';
</script>

README

NodeXH: NodeJS With a Better Exception Handler

Table of Contents generated with DocToc

What It Is

NodeXH is a drop-in wrapper for the NodeJS executable hat provides better stacktraces.

How to Install

npm install -g nodexh

How to Use

Use nodexh path/to/file.js instead of node path/to/file.js, and you're good to go.

What to Expect

  • Stack trace items will be reversed, so most recent calls will be shown last, i.e. also closest to where the cursor of your terminal is.
  • Stack traces will show source contexts (3 lines by default) except where files can not be opened or are NodeJS internals.
  • Source code shown will honor sourcemaps, which is great when you're using the likes of CoffeeScript or TypeScript.
  • The error message will be repeated to avoid having to scroll up when stack traces get longer.
  • Colors!

Related

To Do

  • Add error.name, error.code; where node reports TypeError: TEMPLATES.main_2 is not a function, nodexh only reports EXCEPTION: TEMPLATES.main_2 is not a function
  • visually indicate spot of error (e.g. by reversing)
  • fix async stacktraces (probably not yet handled correctly; might be issue with stackman?)
  • consider utf8ize-sourcemaps in case there should be problems w/ 32bit characters
  • truncate long lines in context
  • offer capabilities of NodeXH as API so applications (such as test libraries) can easily retrieve source code, display source lines with contexts