I have a node project written in typescript. The process runs inside a docker container using Nodemon. node (via nodemon) is run inside the container with the --inspect option.
When I try to connect with Webstorm to the process, it connects but no breakpoints are being hit.
This command used in the package.json to start:
tsc-watch --incremental --onFirstSuccess "sh -c 'tscpaths -p tsconfig.json -s ./src -o ./dist/src && nodemon -L --inspect=0.0.0.0:9229 dist/src/main.js --config nodemon-debug.json'" --onSuccess "sh -c 'tscpaths -p tsconfig.json -s ./src -o ./dist/src && touch ./dist/src/main.js
Explanation:
use tsc-watch to to watch for changes in code.
After first build success run tscpaths to replace path shortcuts, then run nodemon with the inspect option (which is passed to node).
After each build success run tscpaths and touch the main.js file to trigger nodemon to restart the process.
nodemon config (watch only main.js file which is touched after every build by tsc-watch):
{
"watch": [
"./dist/src/main.js"
],
"ext": "js"
}
Port 9229 of the docker container is mapped to port 9666 on the host machine in the docker-compose.yml, and in Webstorm I use the "Attach to Node.js/Chrome" configuration to attach to localhost port 9666.
The tsconfig.json file includes "sourceMap": true.
This whole process of automatic build + restart on every code change works. The debugger is attached in Webstorm (The Debugger tab says "Connected to localhost:9666 - dist/src/main.js"). The problem is that no breakpoints are being hit. They are not marked with a "V" and are not being hit during execution.
Any ideas?
Using Webstorm 2021.1 on Windows 10.
There is something you need to set up in the debugger.
Take a look at the config, and there's something called Remote URLs of local files(optional). You need to specifiy the RemoteURL for your file/directory so it can hit the debugger.