So I'm trying to run the VSCode debugger run my express program, but I noticed that it's messing up the relative directory paths.
When using a module like JIMP
, a Node image manipulator, when I run the app from the Powershell, I need to enter the path relative to the project root (where the package.JSON
is) to find the image. But when I run it from the VSCode debugger, I get an error, because it is finding the image relative to my app
directory, which is a folder in my project root.
Is there a configuration I can edit to fix this?
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"
}
]
}
jsconfig.js
:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
Thanks in advance
Relative Path Extension for VS CodePress Ctrl+Shift+H (Mac: Cmd+Shift+H ) and start typing the file you want.
Alternatively, you can run your configuration through the Command Palette (Ctrl+Shift+P) by filtering on Debug: Select and Start Debugging or typing 'debug ' and selecting the configuration you want to debug. In addition, the debug status appears in the Status Bar showing the active debug configuration.
In the visual studio code, it has commands to Copy Path and Copy Relative Path (Ctrl+Shift+p->File: Copy Path of Active File).
Solved it:
You need to include "cwd": "${workspaceRoot}"
in your launch.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With