共计 950 个字符,预计需要花费 3 分钟才能阅读完成。
通过 vscode 调试 JavaScript 代码,配置如下:
{
// 应用 IntelliSense 理解相干属性。// 悬停以查看现有属性的形容。// 欲了解更多信息,请拜访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// 通过 npm 脚本调试启动配置
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script", // 第一个参数 `run-script` 不要批改
"escheck" //runtimeArgs 的第二个参数,就是 npm scripts 的命令名
// 对应 package.json 中的 scripts 中的 escheck, 要求脚本必须是 node 调用
],
"port": 9229, // 这个端口是调试的端口,不是我的项目启动的端口
"stopOnEntry": true // 启动调试后会,会主动将断点停在代码的第一行
},
// 通过 nodemon 调试启动配置
{
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "nodemon",
"program": "${workspaceFolder}/app.js", // ${workspaceFolder}/app.js 示意了调试的入口
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
我的项目 package.json:
"scripts": {
"test": "echo \"Error: no test specified\"&& exit 1",
"start": "http-server ./",
"check": "es-check es5'./js/*.js'","escheck":"node --inspect-brk=9229 ./node_modules/.bin/es-check es5 './js/*.js'"
},
正文完