[Solved] AppData\Roaming\npm\ng.ps1 cannot be loaded because running scripts is disabled on this system

This error I encountered when I tried to use integrated terminal of visual studio code for executing Angular CLI commands for the first time.

Exception Details:

\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~~

CategoryInfo : SecurityError: (:) [], PSSecurityException

FullyQualifiedErrorId : UnauthorizedAccess

Problem

The issue appear to be security related exception. Also we can observe Unauthorized Access as error Id in exception details.

So the issue is Visual Studio Code could not load ng.ps1 file due to security reasons. Also exception is suggesting to refer Microsoft website article as Visual Studio Code is Microsoft product.

Solution

To solve the issue I could navigate to the file and deleted the ng.ps1 file as shown in below screen shot. After deleting that file I could go ahead with Angular CLI command execution in Visual Studio Code integrated terminal.

Summary

These are some small errors which we can solve if we try to analyze the exception and apply some basic actions.

Default image
Sreenivasa Rangan TR
Software professional with 7+ years of experience in all phases of software development with robust problem-solving skills and proven experience in creating and designing software in a test-driven environment.

Leave a Reply