Why does the node inspector not start when I am using nodemon and ts-node?
18,559
Solution 1
Provide location and port to the inspect option like:
--inspect=0.0.0.0:9200
Solution 2
I just fixed this problem by writing nodemon.json file like this :
{
"restartable": "rs",
"ignore": [".git", "node_modules/**/node_modules"],
"verbose": true,
"execMap": { // [A]
"ts": "node --require ts-node/register"
},
"watch": ["src/"],
"env": {
"NODE_ENV": "development"
},
"ext": "js,json,ts"
}
ref : https://dev.to/oieduardorabelo/nodejs-with-typescript-debug-inside-vscode-and-nodemon-23o7
Author by
Admin
Updated on June 02, 2022Comments
-
Admin almost 2 years
I have a simple node server written in typescript. My package.json is configured as:
"scripts": { "build": "tsc", "dev": "nodemon --watch src/**/* -e ts,json --exec ts-node ./src/server.ts", "debug": "nodemon --verbose --watch src/**/* -e ts,json --exec ts-node --inspect ./src/server.ts" },
When I run
npm run dev
nodemon will launch the server and restart it when any changes are made.[02/28/18 20:45:53] npm run dev > [email protected] dev C:\Users\joe\pq\pq-api > nodemon --watch src/**/* -e ts,json --exec ts-node ./src/server.ts [nodemon] 1.15.1 [nodemon] to restart at any time, enter `rs` [nodemon] watching: src/**/* [nodemon] starting `ts-node ./src/server.ts` initializing config to development info: PQ-API running on port 3000
However, when I run
npm run debug
(so I can attach a debugger) It looks like it begins to start, but just hangs forever[02/28/18 20:39:30] npm run debug > [email protected] debug C:\Users\joe\pq\pq-api > nodemon --verbose --watch src/**/* -e ts,json --exec ts-node --inspect ./src/server.ts [nodemon] 1.15.1 [nodemon] to restart at any time, enter `rs` [nodemon] or send SIGHUP to 10156 to restart [nodemon] watching: src/**/* [nodemon] watching extensions: ts,json [nodemon] starting `ts-node --inspect ./src/server.ts` [nodemon] spawning [nodemon] child pid: 13344 [nodemon] watching 12 files
That is all the output has. The script is never executed; the server never starts up, and the inspector is never available to connect to.
node 8.94
nodemon 1.15.1
ts-node 5.0.0
typescript 2.7.2