我正在尝试使用debug package通过nodemon package为我的应用提供dubug而我正面临着这样的麻烦,即我所需的输出隐藏在杂乱的无关信息中,如您所见
[nodemon] restarting due to changes...
nodemon bus emit: restart +25s
nodemon bus new listener: start (0) +0ms
nodemon bus new listener: start (0) +1ms
[nodemon] starting `node ./build/index.js`
nodemon fork C:\Windows\system32\cmd.exe /d /s /c node ./build/index.js +25s
nodemon bus emit: start +5ms
nodemon bus new listener: exit (2) +1ms
nodemon start watch on: *.* +2ms
[nodemon] restarting due to changes...
nodemon bus emit: restart +4ms
nodemon bus.emit(exit) via SIGUSR2 +218ms
nodemon bus emit: exit +215ms
[nodemon] starting `node ./build/index.js`
nodemon fork C:\Windows\system32\cmd.exe /d /s /c node ./build/index.js +5ms
nodemon bus emit: start +5ms
nodemon bus new listener: exit (1) +1ms
nodemon start watch on: *.* +2ms
app:normal it is normal debugger... +0ms
Listening on port: 3000
^CTerminate batch job (Y/N)? y
E:\Web Apps\RESTful API\express-demo>nodemon ./build/index.js
nodemon bus new listener: reset (0) +0ms
nodemon bus new listener: reset (0) +3ms
nodemon bus new listener: quit (0) +26ms
nodemon bus new listener: quit (0) +0ms
nodemon bus new listener: restart (0) +1ms
nodemon bus new listener: restart (0) +0ms
nodemon bus new listener: reset (2) +6ms
nodemon bus emit: reset +1ms
nodemon resetting watchers +0ms
nodemon reset +0ms
nodemon config: dirs [ 'E:\\Web Apps\\RESTful API\\express-demo' ] +0ms
[nodemon] 1.17.3
[nodemon] to restart at any time, enter `rs`
nodemon bus new listener: error (0) +106ms
nodemon bus new listener: error (0) +0ms
[nodemon] watching: *.*
[nodemon] starting `node ./build/index.js`
nodemon fork C:\Windows\system32\cmd.exe /d /s /c node ./build/index.js +0ms
nodemon bus new listener: exit (0) +12ms
nodemon bus new listener: exit (0) +1ms
nodemon start watch on: *.* +3ms
nodemon start watch on: E:\Web Apps\RESTful API\express-demo +119ms
nodemon ignored [ '**/.git/**',
'**/.nyc_output/**',
'**/.sass-cache/**',
'**/bower_components/**',
'**/coverage/**',
'**/node_modules/**',
re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*/ ] +1ms
nodemon watch is complete +147ms
app:normal it is normal debugger... +0ms
Listening on port: 3000
我正在按照这些命令来调试我的应用
const debug = require('debug')('app:start')
debug('debugging the app... Yup!')
set DEBUG=app:start // inside terminal
nodemon index.js // inside terminal
答案 0 :(得分:0)
问题非常愚蠢,我在不同的终端中运行这两个命令导致问题
set DEBUG=app:start // inside terminal
nodemon index.js // inside terminal
请务必在同一终端中运行这些命令。 希望这会为某人节省时间。