'ts-node' is not recognized as an internal or external command, operable program or batch file

I’m getting error in my Vs Code terminal and command prompt that ‘ts-node’ is not recognized as an internal or external command, operable program or batch file. while i’m trying the start command in the terminal npm run dev and i have added my package.json file also.

{
"name": "tsnode",
"version": "1.0.0",
"description": "ts-node experiment.",
"scripts": {
    "dev": "nodemon --exec 'ts-node --cache-directory .tscache' ./server.ts",
    "start": "ts-node --fast ./server.ts"
},
"author": "Mugesh",
"license": "ISC",
"dependencies": {
    "@types/body-parser": "^1.16.3",
    "@types/chalk": "^0.4.31",
    "@types/express": "^4.0.35",
    "@types/node": "^7.0.18",
    "body-parser": "^1.17.1",
    "chalk": "^1.1.3",
    "express": "^4.15.2",
    "nodemon": "^1.11.0",
    "ts-node": "^3.0.4",
    "typescript": "^2.3.4"
}

}

  • How do I create a Python socket server that listens on a file descriptor?
  • Use Chokidar to watch for specific file extension
  • How should I use moment-timezone with webpack?
  • How to create a cache in node.js that handles explicitly for simultaneous duplicate requests for a CPU-bound operation
  • “Ionic start projectName” not working with Ionic Framework
  • Node.js vs Ruby on Rails
  • Updating multiple MongoDB objects by their unique _id using Node.js
  • How to render doT.js templating in nodejs?
  • dotnet core build in parallel or simultaneously
  • node.js vs IIS 7.5 performance
  • How to create Firebase token on server for use with unit tests?
  • looking for an imagemagick nodejs npm?
  • 2 Solutions collect form web for “'ts-node' is not recognized as an internal or external command, operable program or batch file”

    You need to install ts-node as global

    npm install -g ts-node
    

    More information

    https://github.com/TypeStrong/ts-node

    I just encountered a similar issue: on Mac OS --exec ts-node works, on Windows it doesn’t.

    My workaround is to create a nodemon.json like this:

    {
      "watch": "src/**/*.ts",
      "execMap": {
        "ts": "ts-node"
      }
    }
    

    and change the package.json scripts section to

    "scripts": {
      "start": "nodemon src/index.ts"
    },
    
    Node.js is the Best Javascript runtime in the world.