Description
debug is a tiny JavaScript debugging utility modelled after the debugging technique in Node.js core. It works in Node.js and in web browsers. You create a debug function for a module by giving it the module's name, and it returns a version of console.error that you use for debug statements. You can then switch the output for different parts of a module on or off using the DEBUG environment variable, which takes a space or comma separated list of names. The README includes setup notes for Windows, covering the set command in the Command Prompt and PowerShell syntax, and an example of an npm script that enables debugging. Each debug instance gets a colour generated from its namespace, which makes it easier to see which instance produced a line. In Node.js the colours appear when stderr is a terminal, and installing the supports-color module gives a fuller palette. In browsers, colours appear in inspectors that support the percent-c format option, including WebKit inspectors and Firefox. The utility can also show the number of milliseconds since the previous debug call, which helps measure time between steps while developing. The README sets out conventions for naming namespaces. Because debug is small and has no dependencies, it is often used inside other libraries, which is why it appears in many projects.…
Highlights
- Namespace-based debug output
- DEBUG environment variable switches
- Works in Node.js and browsers
- Colours per namespace
- Millisecond time differences
- Tiny and modelled on Node core debugging
Ratings & Reviews
No ratings yet
Be the first to rate Debug.
People also visit
Debug FAQ
What is debug?
A tiny JavaScript debugging utility modelled after Node.js core's debugging technique, for Node.js and browsers.
How do I turn output on?
Set the DEBUG environment variable to a space or comma separated list of namespaces. The README has notes for Windows Command Prompt and PowerShell.
Why do the lines have colours?
Each namespace is given a colour, so you can tell which debug instance a line came from.
Can it show timing?
Yes. It can show the milliseconds between debug calls.
Which environments does it support?
Node.js and web browsers, according to the README.
Where is it used?
Inside many JavaScript libraries, since it is small and has no dependencies.
What are the best Debug alternatives?
Popular alternatives to Debug include Buffer, Chrome Remote Interface and Bowser. See all Debug alternatives








