gpt4 book ai didi

angular - 为什么我突然得到 : ng : File C:\Users\d\AppData\Roaming\npm\ng. ps1 无法加载

转载 作者:行者123 更新时间:2023-12-05 00:42:35 27 4
gpt4 key购买 nike

多年来,我一直在愉快地使用 vscode/angular/node/npm,没有遇到任何问题。在最后一个小时左右突然没有明确更改任何内容,我收到以下错误。

最有可能导致以前存在的执行权限突然丢失的原因是什么?

我讨厌不得不提前说这些,但对于那些无法理解的人,我并不是在问如何解决这个错误。我在问为什么我的权限被删除导致它出现。

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>

显然这是修复: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 [S] 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

最佳答案

这发生在您的系统中,power shell 还不允许执行任何可执行脚本。此错误主要在 Windows 10 中使用 VS Code IDE 时遇到,其中 Power Shell 默认选择为命令行选项。

您可以通过在同一 Powershell 终端中执行以下 CMD 命令来解决此问题

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

您可以从 this 阅读信息.

否则,您可以删除此文件并再次运行 ng serve。祝你好运!

关于angular - 为什么我突然得到 : ng : File C:\Users\d\AppData\Roaming\npm\ng. ps1 无法加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72863930/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com