[Nodejs] npm install -g 的 package 在 Windows 上出現 cannot be loaded because running scripts is disabled on this system
當在Windows使用npm安裝了一個全域package時,要執行出現"running scripts is disabled"錯誤
例如我想要在Windows 11上安裝dbdocs
npm install -g dbdocs
安裝後執行
PS C:\> dbdocs
dbdocs : File C:\Users\...\AppData\Roaming\npm\dbdocs.ps1 cannot be loaded because running scripts is
disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ dbdocs
+ ~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
解決辦法
Terminal執行以下設定即可
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
留言
張貼留言