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:
typescriptpackage containstsccommand.
Detailed desription
- Ensure that Node.js and
npmcommand 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:
Where:npm install -g typescript-gflag 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
tsccommand:tsc Script.tsNote:
Script.jsfile should be created fromScript.tsfile. - Run compiled program:
node Script.jsOutput:
Hello world! Hello world! Hello world! Hello world! Hello world!
Warning:
tsconfig.jsonfile located in sources directory may change compilation configuration. To solve the problem you can edit the configuration or remove the file.