【发布时间】:2023-01-04 02:57:23
【问题描述】:
多年来,我一直愉快地使用 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
【问题讨论】:
-
删除 ng.ps1,它可能会起作用。
-
我在最初的问题中包含了正确的修复方法。问题是为什么权限一开始就突然消失了。
标签: angular visual-studio-code npm