我有一個我想要全局安裝的NodeJs模塊「some-module」,因此它可以直接從命令行運行,而不需要節點可執行前綴。即:$> some-module [args]
我希望其中一個參數是--debug
。這樣做的原因是我不想要求這個模塊的用戶將它安裝到他們的本地目錄,只是爲了運行node --debug-brk node_modules/some-module/[path to entry point] [args]
。將NodeJs應用程序從其進程內切換到調試模式
在它的NodeJS文檔狀態的調試(http://nodemanual.org/latest/nodejs_ref_guide/debugging.node.js.html)
The V8 debugger can be enabled and accessed either by starting Node.js with the
--debug
command-line flag or by signaling an existing Node.js process withSIGUSR1
.
我試圖這樣做高級用法部分:
process.kill(process.pid, 'SIGUSR1');
其中產生的錯誤:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Unknown signal: SIGUSR1
at EventEmitter.kill (node.js:366:17)
at Object.<anonymous> (c:\dev\some-module\app.js:94:17)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
我需要做什麼才能使運行過程切換到調試模式?
此外,我想用節點檢查器調試給定的應用程序。