VS Code Debugging - Node TypeScript - Source Mapping doesn't work on file name change

3 days ago 7
ARTICLE AD BOX

I'm trying to learn debugging ts with vs code. Js files are generated to 'out' folder with source mapping enabled. In launch.json I've specified to run node against .js file associated with currently opened .ts file.
It works fine with old files - breakpoints are triggered.

The issue is with new files or renamed files. When I copy existed and working file, rebuild .js files and mappings, and then try to debug copied file - its breakpoints are not triggered. Deleting of associated .js and .js.map files and rebuilding them doesn't help. Even deleting of all these files from out directory doesn't help. VS code restart, TS server restart - no effect. I've also played with tsconfig's moduleResolution and module. I see no difference in 'trace' logs from running debug between working and non-working scripts.

The only thing that helps - deleting the 'out' directory directly, and rebuilding .js files.

Here are tsconfig.json, launch.json, code of scripts and the 'project' structure.

{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Bundler", "target": "ES2024", "jsx": "react-jsx", "strictNullChecks": true, "strictFunctionTypes": true, "strict": true, "sourceMap": true, "outDir": "out" }, "exclude": ["node_modules", "**/node_modules/*"] } { // Use IntelliSense to learn about possible 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": "Launch Program", "skipFiles": [ "<node_internals>/**" ], "program": "${workspaceFolder}/out/${fileBasenameNoExtension}.js", "outFiles": [ "${workspaceFolder}/out/**/*.js", ], "sourceMaps": true, "trace": true, "smartStep": false, "console": "integratedTerminal" // Show output in terminal for visibility } ] } // TS code :[ console.log('Hello World');

Project structure

Read Entire Article