1

I am following a tutorial and the guy uses ts-node, so I did the same and installed it through yarn but it showed this error

 ts-node : The term 'ts-node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the    
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ ts-node .\deploy.ts
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (ts-node:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

so I searched a bit and tried to add it globally but it still shows the same error, can you guys help me find out what the issue is, as I want to learn the basics of TypeScript for a quiz tomorrow.

  • Does this answer your question? ['ts-node' is not recognized as an internal or external command, operable program or batch file](https://stackoverflow.com/questions/44764004/ts-node-is-not-recognized-as-an-internal-or-external-command-operable-program) – Mehdi Dehghani Oct 22 '22 at 10:27
  • I added ts-node globally after checking this post but still did not solve the problem, and I could not understand the comments which were told to go to node_modules, (I did not get what to do inside the modules) – Ghulam Mustafa Oct 22 '22 at 10:34

1 Answers1

1
  1. If you are running it just after installation, the console could be missing PATH. Restart your console (or, in my case, VSCode), to get newer executables working

  2. If the yarn global installations don't work, try using

  3. Install locally, as a yarn add --dev ts-node dependency, and run as yarn ts-node. Generally the simpliest solution.

  4. Honestly, try using tsx, it's better IMO
    Just yarn tsx watch deploy would be enough to make your server restart on every file change (I generally add some chechs so the script skips writing if that's file overwrite or deploy script)

Dimava
  • 7,654
  • 1
  • 9
  • 24