<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[debug调试工具 - 模具行业软件开发——模具行业从业者必备知识手册]]></title><description><![CDATA[<p dir="auto">&lt;h2&gt;debug&lt;/h2&gt;<br />
&lt;p&gt;&lt;a href="<a href="https://opencollective.com/debug/backers/badge.svg" rel="nofollow ugc">https://opencollective.com/debug/backers/badge.svg</a>"&gt;&lt;img src="#backers" alt="OpenCollective&lt;/a&gt;"&gt;&lt;/p&gt;<br />
&lt;p&gt;&lt;a href="<a href="https://opencollective.com/debug/sponsors/badge.svg" rel="nofollow ugc">https://opencollective.com/debug/sponsors/badge.svg</a>"&gt;&lt;img src="#sponsors" alt="OpenCollective&lt;/a&gt;"&gt;&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;&lt;img width="647" src="upload://jxcIoeE8SCJlC0o7FjUO216nhfU.png"&gt;&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;A tiny JavaScript debugging utility modelled after Node.js core's debugging&lt;/p&gt;<br />
&lt;p&gt;technique. Works in Node.js and web browsers.&lt;/p&gt;</p>
<p dir="auto">&lt;h3&gt;Installation&lt;/h3&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
$ npm install debug<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;h3&gt;Usage&lt;/h3&gt;</p>
<p dir="auto">&lt;p&gt;&lt;code&gt;debug&lt;/code&gt; exposes a function; simply pass this function the name of your module, and it will return a decorated version of &lt;code&gt;console.error&lt;/code&gt; for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Example &lt;a href="./examples/node/app.js"&gt;<em>app.js</em>&lt;/a&gt;:&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
var debug = require('debug')('http')<br />
, http = require('http')<br />
, name = 'My App';</p>
<p dir="auto">// fake app</p>
<p dir="auto">debug('booting %o', name);</p>
<p dir="auto">http.createServer(function(req, res){<br />
debug(req.method + ' ' + req.url);<br />
res.end('hello\n');<br />
}).listen(3000, function(){<br />
debug('listening');<br />
});</p>
<p dir="auto">// fake worker of some kind</p>
<p dir="auto">require('./worker');<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;p&gt;Example &lt;a href="./examples/node/worker.js"&gt;<em>worker.js</em>&lt;/a&gt;:&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
var a = require('debug')('worker:a')<br />
, b = require('debug')('worker:b');</p>
<p dir="auto">function work() {<br />
a('doing lots of uninteresting work');<br />
setTimeout(work, Math.random() * 1000);<br />
}</p>
<p dir="auto">work();</p>
<p dir="auto">function workb() {<br />
b('doing some work');<br />
setTimeout(workb, Math.random() * 2000);<br />
}</p>
<p dir="auto">workb();<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;p&gt;The &lt;code&gt;DEBUG&lt;/code&gt; environment variable is then used to enable these based on space or&lt;/p&gt;<br />
&lt;p&gt;comma-delimited names.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Here are some examples:&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;&lt;img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="upload://tvIUaxznwuvUO4QIFupYGC6yaJ5.png"&gt;&lt;/p&gt;<br />
&lt;p&gt;&lt;img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="upload://zMim3590sKLQOmTPFa3Msabl6Ur.png"&gt;&lt;/p&gt;<br />
&lt;p&gt;&lt;img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="upload://w0Ihmy0jOMlD7xh6T158BS4l9PS.png"&gt;&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;#### Windows command prompt notes&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;##### CMD&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;On Windows the environment variable is set using the &lt;code&gt;set&lt;/code&gt; command.&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
set DEBUG=*,-not_this<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;p&gt;Example:&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
set DEBUG=* &amp; node app.js<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;p&gt;##### PowerShell (VS Code default)&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;PowerShell uses different syntax to set environment variables.&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
$env:DEBUG = "*,-not_this"<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;p&gt;Example:&lt;/p&gt;</p>
<p dir="auto">&lt;pre&gt;&lt;code&gt;<br />
$env:DEBUG='app';node app.js<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;p&gt;Then, run the program to be debugged as usual.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;npm script example:&lt;/p&gt;<br />
&lt;pre&gt;&lt;code&gt;<br />
"windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js",<br />
&lt;/code&gt;&lt;/pre&gt;</p>
<p dir="auto">&lt;h3&gt;Namespace Colors&lt;/h3&gt;</p>
<p dir="auto">&lt;p&gt;Every debug instance has a color generated for it based on its namespace name.&lt;/p&gt;<br />
&lt;p&gt;This helps when visually parsing the debug output to identify which debug instance&lt;/p&gt;<br />
&lt;p&gt;a debug line belongs to.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;#### Node.js&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;In Node.js, colors are enabled when stderr is a TTY. You also <em>should</em> install&lt;/p&gt;<br />
&lt;p&gt;the &lt;a href="<a href="https://npmjs.org/supports-color" rel="nofollow ugc">https://npmjs.org/supports-color</a>"&gt;&lt;code&gt;supports-color&lt;/code&gt;&lt;/a&gt; module alongside debug,&lt;/p&gt;<br />
&lt;p&gt;otherwise debug will only use a small handful of basic colors.&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;&lt;img width="521" src="<a href="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png" rel="nofollow ugc">https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png</a>"&gt;&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;#### Web Browser&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;Colors are also enabled on "Web Inspectors" that understand the &lt;code&gt;%c&lt;/code&gt; formatting&lt;/p&gt;<br />
&lt;p&gt;option. These are WebKit web inspectors, Firefox (<a href="https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/" rel="nofollow ugc">since version&lt;/p&gt;<br />
&lt;p&gt;31</a>)&lt;/p&gt;<br />
&lt;p&gt;and the Firebug plugin for Firefox (any version).&lt;/p&gt;</p>
<p dir="auto">&lt;p&gt;&lt;img width="524" src="upload://dQu6IqVLizb5lc4IAOLz2fRpFpS.png"&gt;&lt;/p&gt;</p>
<p dir="auto">&lt;h3&gt;Millisecond diff&lt;/h3&gt;</p>
<p dir="auto">&lt;p&gt;When actively developing an application it ca&lt;/p&gt;</p>
<p dir="auto">&lt;hr&gt;<br />
&lt;p&gt;还有什么补充参数吗？一起完善。&lt;/p&gt;</p>
]]></description><link>https://forum.mj7.cn/topic/7193/debug调试工具-模具行业软件开发-模具行业从业者必备知识手册</link><generator>RSS for Node</generator><lastBuildDate>Fri, 02 Oct 2026 10:19:50 GMT</lastBuildDate><atom:link href="https://forum.mj7.cn/topic/7193.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 19 Apr 2026 21:52:12 GMT</pubDate><ttl>60</ttl></channel></rss>