EN
TypeScript - how to install tsc under Windows (TypeScript compiler)
16
points
In this article, we would like to show how to install TypeScript compiler under Windows.
Quick solution:
npm install -g typescript
Note:
typescript
package containstsc
command.
Detailed desription
- Ensure that Node.js and
npm
command are installed
(installation and running instruction is here). - Open some terminal as administrator, e.g. Bash
(an installation instruction is here). - Install TypeScript compiler using:
npm install -g typescript
-g
flag means global installation.
Example output:john@DESKTOP-PC MINGW64 ~ $ npm -g install typescript C:\Users\john\AppData\Roaming\npm\tsc -> C:\Users\john\AppData\Roaming\npm\node_modules\typescript\bin\tsc C:\Users\john\AppData\Roaming\npm\tsserver -> C:\Users\john\AppData\Roaming\npm\node_modules\typescript\bin\tsserver + typescript@4.0.3 updated 1 package in 17.571s
*.ts
compilation instruction
- Create Script.ts file:
for (let i = 0; i < 5; ++i) { console.log('Hello world!'); }
- Run
tsc
command:tsc Script.ts
Note:
Script.js
file should be created fromScript.ts
file. - Run compiled program:
node Script.js
Output:
Hello world! Hello world! Hello world! Hello world! Hello world!
Warning:
tsconfig.json
file located in sources directory may change compilation configuration. To solve the problem you can edit the configuration or remove the file.