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:
xxxxxxxxxx
1
npm install -g typescript
Note:
typescript
package containstsc
command.
- 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:
Where:
xxxxxxxxxx
1npm install -g typescript
-g
flag means global installation.
Example output:xxxxxxxxxx
1john@DESKTOP-PC MINGW64 ~
2$ npm -g install typescript
3C:\Users\john\AppData\Roaming\npm\tsc -> C:\Users\john\AppData\Roaming\npm\node_modules\typescript\bin\tsc
4C:\Users\john\AppData\Roaming\npm\tsserver -> C:\Users\john\AppData\Roaming\npm\node_modules\typescript\bin\tsserver
5+ typescript@4.0.3
6updated 1 package in 17.571s
- Create Script.ts file:
xxxxxxxxxx
1for (let i = 0; i < 5; ++i) {
2console.log('Hello world!');
3}
- Run
tsc
command:xxxxxxxxxx
1tsc Script.ts
Note:
Script.js
file should be created fromScript.ts
file. - Run compiled program:
xxxxxxxxxx
1node Script.js
Output:
xxxxxxxxxx
1Hello world!
2Hello world!
3Hello world!
4Hello world!
5Hello 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.