I can not debug my TypeScript files properly. The problem is that breakpoints in other files then index.ts do not get triggered. VSCode says "Breakpoint set but not yet bound" on them.
How can I get all breakpoints to work?
Backend/index.ts
import { myCoolFunctionFromOtherFile } from "helpers/file2.ts";
// ...
app.get("/", (request, response) => {
console.log("this breakpoint triggers successfully"); // <-- breakpoint triggers
myCoolFunctionFromOtherFile();
});
Backend/helpers/file2.ts
export const myCoolFunctionFromOtherFile = () => {
console.log("This breakpoint will not be triggered"); // <-- Breakpoint will not break. VSCode says "Breakpoint set but not yet bound".
};
Backend/Dockerfile
FROM node:13-alpine
RUN mkdir /app
WORKDIR /app
COPY package*.json /app/
RUN npm install
COPY . /app
EXPOSE 3000
EXPOSE 9229
ENTRYPOINT ["npm", "run", "debug"]
Backend/package.json
"scripts": {
"debug": "ts-node-dev --poll --inspect=0.0.0.0:9229 --respawn index.ts", // I also tried nodemon, but could not get either to work
launch.json
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Docker",
"protocol": "inspector",
"port": 9229,
"restart": true,
"localRoot": "${workspaceFolder}/Backend",
"remoteRoot": "/app",
"sourceMaps": true,
}
]
fyi: When trying to debug locally without docker (run the scripts directly on my machine), then debugging works correctly. So I think it's some configuration error.
Edit 1
Add tsconfig.json
Enable inlineSourceMap and inlineSources
Also enable sourceMaps in launch.json
Backend/tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es6", "dom"],
"module": "commonjs",
"outDir": "build",
"resolveJsonModule": true,
"rootDir": "source",
"strict": true,
"target": "es5",
"inlineSourceMap": true,
"inlineSources": true
},
"include": ["source"]
}