The file tsc.ps1 is not digitally signed. You cannot run this script on the current system…

Run into the following bug trying to get TypeScript up and running in VSCode on your Windows machine?

The file tsc.ps1 is not digitally signed. You cannot run this script on the
current system. For more information about running scripts and setting execution policy, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

Okay so here’s the deal. You probably installed the TypeScript compiler using the Windows Command Prompt or possibly the built-in PowerShell terminal from within VSCode. Installing TypeScript using the Command Prompt or the built-in terminal in VSCode will both cause your system to throw the nasty error above when you actually attempt to start using the TypeScript compiler.

Okay so… then what do we need to do? Well here’s your answer:

First, uninstall TypeScript.

$ npm uninstall -g typescript

Next, open up the Windows PowerShell (not the built-in PowerShell in VSCode) making sure to run the program as an administrator. If you don’t know how to do this, search for “PowerShell” in the search bar next to the Windows Start Button in the lower left and corner of your screen. Then right-click on “Windows PowerShell” and select “Run as administrator”. From the Windows PowerShell, you can now re-install TypeScript with administrator privileges which will fix the permissions related bug mentioned above.

$ npm install -g typescript

Now go ahead and re-open your TypeScript project in VSCode and compile it like normal, and everything should work A-okay 👌.

 

topherPedersen