前端 nodejs debug npm脚本

lixin1182905103 · April 19, 2020 · 6 hits

本文介绍在 vscode 下 debug npm 脚本的方法
1、npm 运行的 node 命令,有些工具回自动判断调试模式,如 egg-bin ,如果 node 包不支持,则手动在脚本中增加调试模式,如下

1
2
3
4
5
6
7
@IF EXIST "%~dp0node.exe" (
"%~dp0node.exe" "D:front_workspaceproduct_workspacecdf-clientpackagescdf-clibincli.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node --inspect-brk "%~dp0node_modulescdf-clibincli.js" %*
)

2、在 vscode bug 面板中增加以下配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"console": "integratedTerminal",
"runtimeArgs": [
"run",
"dev"
"--",
"--inspect-brk"
],
"port": 9229,
"autoAttachChildProcesses": true
}
]
No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.