I’m encountering unbound breakpoints in VSCode when debugging a TypeScript project running in Docker.
Despite this, breakpoints remain unbound. What could be causing this issue and how can I resolve it?
My setup includes a launch.json configuration to attach to Node.js processes. Here’s my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name" : "collector",
"type": "node",
"request": "attach",
"port": 9229,
"restart": true,
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app",
"sourceMaps": true
},
{
"name" : "worker",
"type": "node",
"request": "attach",
"port": 9230,
"restart": true,
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app",
"sourceMaps": true
}
]
}
My tsconfig.json has sourceMap enabled, and my Docker setup mounts the project to /app:
{
"compilerOptions": {
"target": "es2022",
"lib": ["ES2022"],
"module": "node16",
"moduleResolution": "node16",
"outDir": "./dist",
"module": "nodenext",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"sourceMap": true
}
}
collector:
build:
context: .
target: collector
depends_on:
- postgres
- redis
environment:
......
ports:
- 3000:3000
- 9229:9229 # Debug port
volumes:
- ./collector:/app/collector:ro
- ./shared:/app/shared:ro
command: [
"npx",
"nodemon",
"--signal", "SIGINT",
"--nolazy",
"--watch", "collector/**/*.ts",
"--watch", "shared/**/*.ts",
"--ext", "ts",
"--exec", "node --inspect=0.0.0.0:9229 -r ts-node/register",
"collector/server.ts",
]
workers:
build:
context: .
target: workers
depends_on:
- postgres
- redis
environment:
....
ports:
- 9230:9229 # Debug port
volumes:
- ./workers:/app/workers:ro
- ./shared:/app/shared:ro
command: [
"npx",
"nodemon",
"--signal", "SIGINT",
"--nolazy",
"--watch", "workers/**/*.ts",
"--watch", "shared/**/*.ts",
"--ext", "ts",
"--exec", "node --inspect=0.0.0.0:9229 -r ts-node/register",
"workers/master.ts"
]
Directory structure
.
├── collector
└── workers
├── node_modules
├── postgres
├── prisma
├── redis
├── shared
├── package.json
├── tsconfig.json