'How to fix "running scripts is disabled on this system"?
When I try to run ionic commands like ionic serve
in the terminal in VS Code, it gives the following error. How can I fix this?
ionic : File C:\Users\Lakshan\AppData\Roaming\npm\ionic.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
+ ~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Solution 1:[1]
I found a way to fix this error. It is as follows,
First Open powerShell as Run as Administrator.
Then, run this command in PowerShell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
After that type Y
and press enter.
Solution 2:[2]
This is because of Execution Policy. This defines how powershell scripts will run.
In Default windows desktops, it is Restricted, not allowing any scripts (signed or unsigned) only interactive sessions.
So best is you set using RemoteSigned
(Default on Windows Server) letting only signed scripts from remote and unsigned in local to run, but Unrestriced
is insecure lettting all scripts to run.
To set run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
as administrator.
Solution 3:[3]
To Bypass this you need to change the Execution policy. Type this into your terminal.
Set-ExecutionPolicy -Scope CurrentUser
then it will prompt you to supply a value at which point you can set Bypass / RemoteSigned or Restricted.
cmdlet Set-ExecutionPolicy at command pipeline position 1
Supply values for the following parameters:
ExecutionPolicy: "RemoteSigned" or "Bypass" or "Restricted".
Solution 4:[4]
This code will fix it:
Set-ExecutionPolicy RemoteSigned –Scope Process
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Wasif |
Solution 3 | Aurelien Essome |
Solution 4 | Jeremy Caney |