以下を使用して node-inspector と nodemon をインストールする必要があります。
npm install -g nodemon
npm install -g node-inspector
Windows で実行するには、新しい .bat ファイルを作成し、次の行を追加します。
@echo off
echo Starting developer enviroment of the file %1
start nodemon --debug-brk %1
node-debug %1
そして実行します:
node_desarrollo.bat "実行するファイル名.js"
エラーで実行された場合:
Error: listen EADDRINUSE :::5858
at Object.exports._errnoException (util.js:855:11)
at exports._exceptionWithHostPort (util.js:878:20)
at Agent.Server._listen2 (net.js:1237:14)
at listen (net.js:1273:10)
at Agent.Server.listen (net.js:1369:5)
at Object.start (_debug_agent.js:21:9)
at startup (node.js:72:9)
at node.js:980:3
node-inspector が接続するためにそのポートを開く必要があるため、これは正常ですnodemon --debug-brk %1
が、5858 ポートが開かれたため、開くことができず、EADDRINUSE :::5858
エラーが表示されます--debug-brk
。nodemon のフラグは、最初の行にブレークポイントを作成する必要があることに注意してください。.bat を実行した後に file.js を変更してみて、変更がデバッガーに反映されていることを確認してください。このデバッガーが再起動し、file.js で行われた変更が表示されます。ハッピーコーディングJS!!!