tsc is not recognized as internal or external command
Solution 1:
There might be a reason that Typescript
is not installed globally, so install it
npm install -g typescript // installs typescript globally
If you want to convert .ts
files into .js
, do this as per your need
tsc path/file.ts // file.ts will be converted to file.js
tsc // all .ts files will be converted to .js files with in the directory
tsc --watch // converts all .ts files to .js, and watch changes in .ts files
Solution 2:
The problem is that tsc
is not in your PATH
if installed locally.
You should modify your .vscode/tasks.json
to include full path to tsc
.
The line to change is probably equal to "command": "tsc"
.
You should change it to "command": "node"
and add the following to your args: "args": ["${workspaceRoot}\\node_modules\\typescript\\bin\\tsc"]
(on Windows).
This will instruct VSCode to:
- Run NodeJS (it should be installed globally).
- Pass your local Typescript installation as the script to run.
(that's pretty much what tsc
executable does)
Are you sure you don't want to install Typescript globally? It should make things easier, especially if you're just starting to use it.