Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular - ng.ps1 cannot be loaded because running scripts is disabled on this system

Tags:

angular

In my Angular-12 Application, I tried to generate service using:

ng g s auth/services/login

but I got this error:

ng : File C:\Users\akweey\AppData\Roaming\npm\ng.ps1 cannot be loaded because running scripts is disabled on this system. For more 
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ ng g s auth/services/login
+ ~~
+ CategoryInfo          : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

When I checked the path: C:\Users\akweey\AppData\Roaming\npm\ng.ps1,

I only found ng but no ng.ps1

How do I get this resolved?

Thanks

like image 221
user11352561 Avatar asked Dec 05 '22 08:12

user11352561


2 Answers

This issue occurs due to undefined Execution policy.

Try this command in Powershell:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
like image 139
Drashti Dobariya Avatar answered May 15 '23 08:05

Drashti Dobariya


Just delete this file. C:\Users\username\AppData\Roaming\npm\ng.ps1

like image 20
gbroz dev Avatar answered May 15 '23 07:05

gbroz dev