Prerequisites

Node and NPM have to be installed, so navigate to NodeJs official website and grab the installer best suited for your system.

To test if it’s installed and if it work you can open your command prompt(or bash or whatever you use) and type these two commands:

node -v
npm -v

both will show the version number of the installed Node and NPM.

Installing TypeScript

To install TypeScript open a command pront and type:

npm install -g typescript

The -g option will install the package globally, so that the ocmpiler can be used in any project. To test if it works just type:

tsc -v
tsc -h

To print out the compiler version number and an help of all the available options.

Fixing the Issue with multiple versions installed

It’s always a good idea to check if you have the latest version available: if the displayed version number it’s not what you expect it to be - especially after having updated all your global packages - chances are you have multiple copies of the package installed on your machine, and the default path is pointing you to an outdated one. Fix the issue on a Windows machine is not that hard, just look and the paths defined in the environment system variables and point the to the newly installed version of typescript.

In my case I had to open the ‘Control Panel’, select ‘System’ and then ‘Advanced System Settings’; looking and the System enviroment variables, under the PATH option I could read: …C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0... Which was pointing to an outdated version of the compiler. Find where the newly installed version is on your system (usually inside C:\Program Files (x86)\Microsoft SDKs\TypeScript) and fix the path.

As a hint you can:

  • Install a propert SDK from Microsoft, and look under C:\Program Files (x86)\Microsoft SDKs\TypeScript.
  • Manually update the npm package (npm install -g typescript) and take note of the paths that will be printed out by the installer:
C:\Temp\typescript>npm install -g typescript
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@1.5.3 C:\Users\Username\AppData\Roaming\npm\node_modules\typescript

Keep TypeScript Updated

To update Node.js global packages, you can use:

npm install -g typescript

To find out which packages need to be updated, you can use:

npm outdated -g --depth=0

To update all global packages, you can use:

npm update -g

Grab a good editor, possibly with TypeScript support

There are many editors out there, some are listed on the TypeScript Website.

On a Windows OS I’d like to recommend:

On other operating systems you can check Visual Studio Code as well, it’s currently available for Linux and Mac OSX too.

cya next

Comments