我正在尝试在 Visual Studio Code 上调试我的应用程序。我有以下配置package.json
:
"scripts": {
"build": "rimraf dist/ && babel ./ --out-dir dist/ --ignore ./node_modules,./.babelrc,./package.json,./npm-debug.log --copy-files",
"start": "npm run build && node --inspect=12345 dist/app.js"
}
我在我的 Node 应用程序上使用 ES6,这就是为什么我的build
配置有点混乱。
当我运行npm start
一切正常时,我可以使用我的应用程序。
现在尝试调试它,我设置了以下launch
配置:
"configurations": [
{
"type": "node",
"name": "Attach to Remote",
"request": "attach",
"port": 12345
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\dist\\app.js"
}
]
他们都“工作”:VS Code 切换到“调试模式”,但我无法找到任何断点。他们都变灰了:
我曾尝试使用此答案进行修复,但无法使其正常工作...
有什么帮助吗?
提前致谢!
我发现我只是--source-maps
从我的babel-cli
命令中遗漏了... -.- 添加它后,VSCode 能够找到断点。所以基本上解决方案是:
添加--source-maps
到我的构建命令:
"scripts": {
"build": "rimraf dist/ && babel ./ --out-dir dist/ --ignore ./node_modules,./.babelrc,./package.json,./npm-debug.log --copy-files --source-maps",
"start": "npm run build && node --inspect=12345 dist/app.js"
}
我配置了一个launch
如下:
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\dist\\app.js",
"preLaunchTask": "npm: build"
}
]
希望它可以帮助某人!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句