I am trying to run a mand tsc
for a file.ts
as to pile this code to js
but I fins the below error:
tsc : File C:\Program Files\nodejs\tsc.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft/fwlink/?LinkID=135170.
At line:1 char:1
+ tsc test.ts
+ ~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
and here's a screen shot of my Editor
:
any one knows how can I solve this error?
I am trying to run a mand tsc
for a file.ts
as to pile this code to js
but I fins the below error:
tsc : File C:\Program Files\nodejs\tsc.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft./fwlink/?LinkID=135170.
At line:1 char:1
+ tsc test.ts
+ ~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
and here's a screen shot of my Editor
:
any one knows how can I solve this error?
Share Improve this question asked Jun 25, 2020 at 9:48 Mahmoud Al-HaroonMahmoud Al-Haroon 2,4498 gold badges46 silver badges83 bronze badges 2- 1 Have a look at learn.microsoft./en-us/powershell/module/… – Umair Khan Commented Jun 25, 2020 at 9:51
- @UmairKhan thanks for your ment I hope you can let me know the direct answer or small explanation bout this – Mahmoud Al-Haroon Commented Jun 25, 2020 at 9:58
2 Answers
Reset to default 13PowerShell
has some Execution Policies which tell PS
what to do if user tries to execute some code or script.
If the execution policy is Undefined, which is mostly the case, the applied policy is Restricted.
As defined in Restricted Policy
, all script files execution is prevented.
Prevents running of all script files, including formatting and configuration files (
.ps1xml
), module script files (.psm1
), and PowerShell profiles (.ps1
).
You can check your current execution policy by running this mand in PS
as advised here.
Get-ExecutionPolicy
OR
Get-ExecutionPolicy -List
You can change execution policy like
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser
Keep in mind
In Windows Vista and later versions of Windows, to run mands that change the execution policy for the local puter, LocalMachine scope, start
PowerShell
with the Run as administrator option.
Hope this helps.
To solve this problem;
Runs Powershell as administrator.
Later could you try this:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
Then run the script
Type Y.