Sunday, January 24, 2021

Typescript setup on MacOS.

I finally updated my laptop from a 2013 MacBook Pro to a 2020 MacBook Pro. I treat my computers like an applicance, so I do not generally upgrade or change anything. Having said that, things change over 7 years. I use MacPorts. I am using visual studio code for typescript development.
I will assume that macports is already installed.

The first thing we need to do is install the javascript package manager, npm.
sudo port install npm6

There's a note of interest if you every want to no longer use npm.
  npm6 has the following notes:
    It is not recommended to install packages globally. But if you do so please
    be aware that they won't get cleaned up when you deactivate or uninstall
    npm6. Globally installed packages will remain in
    /opt/local/lib/node_modules/ until you manually delete them.

Now it's time to install the typescript compiler.
 sudo npm install -g typescript

Here's the notes on where it installed things:
/opt/local/bin/tsc -> /opt/local/lib/node_modules/typescript/bin/tsc
/opt/local/bin/tsserver -> /opt/local/lib/node_modules/typescript/bin/tsserver
+ typescript@4.1.3

Now try it. Let's see if we can see the tcs typescript compiler.
% tcs
zsh: command not found: tcs

Okay, so this means that either 1) we didn't actually install it or 2) it's not in the path. The first thing to try is the "rehash" command.
rehash

Now on to try tsc again.
% tsc  --version
Version 4.1.3

And that means success.

No comments:

Post a Comment