How to solve 因為這個系統上已停用指令碼執行,所以無法載入…

How to solve 因為這個系統上已停用指令碼執行,所以無法載入…

這篇介紹How to solve 因為這個系統上已停用指令碼執行,所以無法載入…。

發生情境

1
2
3
4
5
6
7
8
9
10
11
在VisualStudioCode terminal 執行 eslint --init指令時,
出現
eslint : 因為這個系統上已停用指令碼執行,所以無法載入 C:\Users\xxx\AppData\Roaming\npm\eslint.ps1 檔案。
如需詳細資訊,請參閱 about_Execution_Policies,網址為 https:/go.microsoft.com/fwlink/?LinkID=135
170。
位於 線路:1 字元:1
+ eslint --init
+ ~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

解決方法

1
2
3
4
5
6
7
8
9
使用系統管理員開啟Windows PowerShell
$ Set-ExecutionPolicy RemoteSigned

執行原則變更
執行原則有助於防範您不信任的指令碼。如果變更執行原則,可能會使您接觸到 about_Execution_Policies 說明主題 (網址為
https:/go.microsoft.com/fwlink/?LinkID=135170) 中所述的安全性風險。您要變更執行原則嗎?
[Y] 是(Y) [A] 全部皆是(A) [N] 否(N) [L] 全部皆否(L) [S] 暫停(S) [?] 說明 (預設值為 "N"):

$ A