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

1769
January 13, 2017, at 08:54 AM

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
`-- typescript@2.1.5

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?

Answer 1

I tried using the command line to set the target.

tsc first.ts --target ES5

This created the first.js( compiled type script in javascript format).I manually moved this file to scripts folder.

Now when i ran the server using lite-server command. The browser could find the first.js file and ran the typescript code.

Answer 2

Have you tried running tsc --init in your directory? This will create a tsconfig.json file in your directory where you can define your configuration. VSCode will also start using this file once it finds it in your root directory.

Check out tsconfig.json documentation for more details.

READ ALSO
Tell selenium to wait 5 seconds, then close browser; using NodeJS

Tell selenium to wait 5 seconds, then close browser; using NodeJS

Using selenium, and NodeJS, I would like to simply open a browser, wait 5 seconds, then close the browserWhat am i doing wrong?

135
BluebirdJS bind() in AWS Lambda

BluebirdJS bind() in AWS Lambda

I'm having some weird behavior in a nodejs AWS lambda function

151
TypeError while building polling app using Node and RethinkDB

TypeError while building polling app using Node and RethinkDB

I'm following an online tutorial building a polling app using node and rethinkdbI created a class of polls in the models directory that has a getAllPolls function

161
url-to-image renders every URL I try except the one I need

url-to-image renders every URL I try except the one I need

I'm trying to implement the apparently useful and powerful url-to-image moduleUsing the basic example script, I can render and save as a

117