Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

typescript: tsc is not recognized as an internal or external command, operable program or batch file

I am a beginner with type script. I am unable to compile the type script file.

As I hit Ctrl+Shift+B in the VS Code, i get the error "tsc is not recognised"

I used npm while downloading transcript.

C:\Users\sramesh>npm install -g typescript
C:\Users\sramesh\AppData\Roaming\npm\tsserver -> C:\Users\sramesh\AppData\Roaming\npm\node_modules\typescript\bin\tsserver
C:\Users\sramesh\AppData\Roaming\npm\tsc -> C:\Users\sramesh\AppData\Roaming\npm\node_modules\typescript\bin\tsc
C:\Users\sramesh\AppData\Roaming\npm
`-- [email protected]

Here is my tasks.json file

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "C:\\Users\\sramesh\\AppData\\Roaming\\npm\\node_modules\\typescript\\bin\\tsc",
    "isShellCommand": true,
    "args": [],
    "showOutput": "silent",
    "problemMatcher": "$tsc"
}

Can anyone help?

like image 640
codingyo Avatar asked Jan 12 '17 23:01

codingyo


2 Answers

I'm using Windows OS and For some reason the marked answer didn't work for me.I tried tsc--init and i was returned the same error.I updated the path variable to C:\Users\"UserName"\AppData\Roaming\npm and this worked..

Note:replace Username with your own Username

like image 182
Shardul Birje Avatar answered Oct 08 '22 08:10

Shardul Birje


I had a similar issue and didn't even showed the version of Typescript after typing tsc -v. Even i had to scratch my head for few days and couldn't solve it.

At last i did 4 things.

  1. installed latest version of nodejs which is i.e. 8.1.3
  2. installed npm which is 5.1.0 ( npm install npm@latest -g)
  3. installed typescript 2.4.1 ( npm install -g typescript)
  4. as suggested by @Uzair Sajid above. (tsc --init)

Now, I can see the TS version, and also compile the TS code.

like image 44
Pramod Kumar Sharma Avatar answered Oct 08 '22 09:10

Pramod Kumar Sharma