why am I suddenly getting: ng : File C:\Users\d\AppData\Roaming\npm\ng.ps1 cannot be loaded

Discussão em 'Angular' iniciado por m12lrpv, Novembro 20, 2024.

  1. m12lrpv

    m12lrpv Guest

    I've been happily using vscode/angular/node/npm for years without issue. Suddenly in the last hour or so without explicitly changing anything I'm getting the following error.

    What are the most likely causes for the execute permissions, that were previously there, to suddenly be lost?

    I hate having to say this in advance but to those that cannot comprehend I'm not asking about how to fix the error. I'm asking why my permissions were wiped causing it to appear.

    Windows PowerShell
    Copyright (C) Microsoft Corporation. All rights reserved.

    Try the new cross-platform PowerShell https://aka.ms/pscore6

    PS C:\Users\d> cd C:\source\my-WebApp
    PS C:\source\my-WebApp> ng serve
    ng : File C:\Users\d\AppData\Roaming\npm\ng.ps1 cannot be loaded. The file
    C:\Users\d\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 serve
    + ~~
    + CategoryInfo : SecurityError: :)) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
    PS C:\source\my-WebApp>


    Obviously this is the fix: PS C:\source\my-WebApp> Get-ExecutionPolicy -list

    Scope ExecutionPolicy
    ----- ---------------
    MachinePolicy Undefined
    UserPolicy Undefined
    Process Undefined
    CurrentUser Undefined
    LocalMachine AllSigned


    PS C:\source\my-WebApp> set-ExecutionPolicy RemoteSigned -Scope CurrentUse

    Execution Policy Change
    The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
    you to the security risks described in the about_Execution_Policies help topic at
    https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
    [Y] Yes [A] Yes to All [N] No [L] No to All Suspend [?] Help (default is "N"): Y
    PS C:\source\my-WebApp> Get-ExecutionPolicy -list

    Scope ExecutionPolicy
    ----- ---------------
    MachinePolicy Undefined
    UserPolicy Undefined
    Process Undefined
    CurrentUser RemoteSigned
    LocalMachine AllSigned

    Continue reading...

Compartilhe esta Página