Owe*_*n M 4 javascript debugging npm visual-studio-code
所以我试图运行VSCode调试器运行我的express程序,但是我注意到它弄乱了相对目录路径。
当使用诸如JIMP
Node图像操纵器之类的模块时,当我从Powershell运行应用程序时,我需要输入相对于项目根目录的路径(“ package.JSON
is” 所在的位置)以查找图像。但是,当我从VSCode调试器运行它时,出现一个错误,因为它正在查找相对于我的app
目录的图像,该目录是我的项目根目录中的一个文件夹。
有可以修改的配置可以解决此问题吗?
launch.json
:
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "npm start",
"program": "${workspaceRoot}/app/app.js"
}
]
}
Run Code Online (Sandbox Code Playgroud)
jsconfig.js
:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
Run Code Online (Sandbox Code Playgroud)
提前致谢
解决了:
您需要包括"cwd": "${workspaceRoot}"
在您的launch.json
归档时间: |
|
查看次数: |
1068 次 |
最近记录: |