
December 17, 2024 06:08 by
Peter
When we run a typescript version checking command,
tsc -v

We may get error in either PowerShell prompt or Visual Studio or VS Code terminal, such as

However, if we run this same command from a command line prompt, such as Windows Colose, we can get the result:

We can see something like this

There are some articles to discuss this issue, but most of them went to a wrong answer. Actually, it is not true. From the PowerShell window, we can see:

The execution policy isn't a security system that restricts user actions. For example, users can easily bypass a policy by typing the script contents at the command line when they cannot run a script. Instead, the execution policy helps users to set basic rules and prevents them from violating them unintentionally.
Such as

The default for local Machine is Restricted

That is the reason that we cannot run the 'tsc' command from PowerShell or Visual studio and VS code terminal.
How to Fix?
Set it to ByPass:

You must be an admin role when opening the prompt:

Or
