OiO.lk Blog javascript How to fix 15: exec: node: not found in a NodeJS project with Typescript on Windows?
javascript

How to fix 15: exec: node: not found in a NodeJS project with Typescript on Windows?


I’m new to Nodejs and Typescript and facing a problem on a Windows machine. I set up an empty project with a single index.ts just for testing. I’m also using nodemon.

When I use tsc command to generate js files from ts, it works without any error and the files are built in the build directory.

But when I want to do that using the node’s start script (using nodemon), it throws an error.

Any ideas why it happens and how to fix it?

Node, ts-node, tsc are installed:

Here is my package.json:

{
  "name": "signal-service",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "nodemon"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "devDependencies": {
    "@tsconfig/node20": "^20.1.4",
    "@types/node": "^22.7.7",
    "nodemon": "^3.1.7",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.3"
  }
}

Here is my tsconfig.json:

{
  "extends": "@tsconfig/node20/tsconfig.json",
  "compilerOptions": {
    "rootDir": "./src",
    "outDir": "./build",
    "forceConsistentCasingInFileNames": true
  },
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "node_modules",
    "build"
  ]
}

Here is my nodemon.json:

{
  "watch": [
    "src"
  ],
  "ext": "js,ts,json",
  "exec": "ts-node ./src/index.ts"
}

I tried reinstall node on my machine and set up a project from scratch a few times.



You need to sign in to view this answers

Exit mobile version