問題
我在 Windows 11 上透過 VSCode 的終端機嘗試執行我的 express 指令碼,結果收到以下 PowerShell 錯誤:
cannot be loaded because running scripts is disabled on this system.For more information, seeabout_Execution_Policies at https: /go.microsoft.com/fwlink /? LinkID = 135170.At line: 1 char: 1 + nodemon server + ~~~~~~~ + CategoryInfo : SecurityError: (:)[], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess那個連結對我來說沒有用。
幸運的是,有一個簡單的修正方法。
解決方案
前往「設定」>「系統」>「開發人員專用」。
找到 PowerShell,然後開啟這個選項:
變更執行原則。 -> 開啟
現在再次執行你的指令碼,應該就能正常運作。第一次執行時,系統可能會詢問你是否允許執行。