node.js – Unable to show messages from console.log function from a typescript script

I’m running one node.js application with “npm run dev” without problems and there are some typescript scripts/files. I’m using nodemon to run my code:

this is my package.json:

{
  "scripts": {
    "start": "ts-node ./src/index.ts",
    "dev": "nodemon --watch \"./src/**/*.ts\" --exec \"ts-node\" ./src/index.ts"
  },
  "devDependencies": {
    "@types/express": "^4.17.2",
    "@types/socket.io": "^2.1.4",
    "nodemon": "^2.0.22",
    "ts-node": "^8.10.2",
    "typescript": "^3.7.2"
  },
  "dependencies": {
    "express": "^4.17.1",
    "socket.io": "^2.3.0"
  }
}

And this is my file structure:

enter image description here

I want show the console.log messages in the console that I have written in the server.ts file but I’m unable to show it.

I tried using –inspect flag in the dev key:

"dev": "nodemon --watch \"./src/**/*.ts\" --exec \"ts-node\" ./src/index.ts"

so being that way:

"dev": "nodemon --inspect --watch \"./src/**/*.ts\" --exec \"ts-node\" ./src/index.ts"

however I got one error:

Unknown or unexpected option: --inspect

I also tested:

--inspect-brk

And I got Unknown or unexpected option: –inspect-brk

As we can see:

enter image description here

no message is showed in the console from the typescript files. I would like to know how I can fix this problem by using nodemon or avoiding it. thanks so much.

Read more here: Source link