'tsc' is not recognized as the name of a cmdlet code example

Example: tsc types.ts 'tsc' is not recognized as an internal or external command, operable program or batch file.

1. Install as global package

To make TypeScript compiler available to all directories for this user, run the below command:

npm install -g typescript
You will see something similar to

C:\Users\username\AppData\Roaming\npm\tsserver -> C:\Users\username\AppData\Roaming\npm\node_modules\typescript\bin\tsserver C:\Users\username\AppData\Roaming\npm\tsc -> C:\Users\username\AppData\Roaming\npm\node_modules\typescript\bin\tsc + typescript@3.6.3 added 1 package from 1 contributor in 4.769s

2. Set the environment variable

Add the npm installation folder to your "user variables" AND "environment variables".

In windows you can add environment variable PATH with value

C:\Users\username\AppData\Roaming\npm\

i.e. wherever the npm installation folder is present.

Note: If multiple Paths are present separate them with a ;(semicolon)

If the below command gives the version then you have successfully installed

tsc --version