Solution: ng.ps1 cannot be loaded, The file is not digitally signed.
How to resolve \"ng.ps1 cannot be loaded, the file is not digitally signed\" when attempting to run commands \"ng serve\" or \"ng new\" in a Visual Studio Code terminal for an Angular project setup.
Last updated on 11/21/2021
- Open up Windows Powershell as Administrator
- Run the following command:
- You should be able to now run commands in the Visual Studio Code terminal for Angular and Node.js.
I was trying to create my first Angular project using Visual Studio code, I successfully got the Angular CLI installed alongside Node.js. But when I tried to run the command ng new (also errors for ng serve command) I was met with the following error message:
ng : File C:\Users\AppData\Roaming\npm\ng.ps1 cannot be loaded. The file C:\Users\AppData\Roaming\npm\ng.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. At line:1 char:1 + ng new + ~~ + CategoryInfo : SecurityError: (:) , PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
I was able to resolve this error message by opening Windows Powershell as Administrator and then running the following command:
This error is thrown because Windows does not want just any random powershell script to run on your machine. For more information about this command please read Microsoft's Article - About Execution Policies.
Additional Links that may be helpful:
Thanks for reading and I hope this solution helped you out when setting up your first Angular project in Visual Studio Code.