In this article, I am going to explain how to fix the error The file C:\Users\admin\AppData\Roaming\npm\ng.ps1 is not digitally signed.
I working with an angular application and recently when I compiled and run my angular application using ng s --open Powershell command, I got the following error:
ng: File C: \Users\admin\AppData\Roaming\npm\ng.ps1 cannot be loaded.The file C: \Users\admin\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 s--open + ~~ + CategoryInfo : SecurityError: (:)[], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
This error indicates that your device is stopping you from executing or running the script files. Implementation of those regulations takes place on Windows systems inclusive of Windows client or Windows Server machines.
The PowerShell has the following execution policies, formatting, and configuration files which have (.ps1xml) file extension, module script files which have (.psm1) file extension and PowerShell profiles have a (.ps1) file extension.
I have searched many solutions for the same over the internet but most of the solutions did not work for me and finally, I got the solution to fix this error that I wanted to share with you. You can follow the given steps to fix the angular PowerShell error.
In my previous articles, I explained many topics on create angular project, crud in angular, charts in angular, angular with bootstrap, angularJS, Microsoft excel upload and angular crud with web api and etc, that you might like to read.
Implementation
So, let's start with a solution for this error.
Step 1: Open the PowerShell window with the administrative rights and then execute the following command.
Get-ExecutionPolicy -List
As you can see in the Execution Policy list, there is a CurrentUser marked as Undefined as well as LocalMachine is defined as Restricted, So we have to fix it and mark them as AllSigned.
Step 2: Now, execute the following command in the PowerShell window.
Set-ExecutionPolicy -ExecutionPolicy AllSigned -Scope CurrentUser
Set-ExecutionPolicy -ExecutionPolicy AllSigned -Scope LocalMachine
Step 3: When you again execute the following command, you can see the CurrentUser and LocalMachine marked as AllSigned and the issue has been resolved. Now you can run your angular application without any error.
Summary
In this article we learned, way to fix PowerShell ng.ps1 can not be loaded and not digitally signed related error for angular application as well as we learn PowerShell ExecutionPolicy and their states and PowerShell command for the change it.
Let me know if you still facing any errors, I will help you. You can drop your comments or you can directly contact me by visiting the contact us page.