0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PowerShell 実行ポリシー

Posted at

VSCodeから ng serve などのスクリプトを実行するとセキュリティーエラーが発生することがあります。

PS > ng serve       
ng : このシステムではスクリプトの実行が無効になっているため、ファイル C:\Program Files\nodejs\ng.ps1 
を読み込むことができません。詳細については、「about_Execution_Policies」(https://go.microsoft.com/fwli 
nk/?LinkID=135170) を参照してください。
発生場所 行:1 文字:1
+ ng serve
+ ~~
    + CategoryInfo          : セキュリティ エラー: (: ) []、PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

悪意のあるスクリプト実行を防ぐために用意されている機能で
デフォルトではスクリプト事項できない設定になっています。

PS > Get-ExecutionPolicy
Restricted

次のコマンドを実行すると、ログインユーザの実行ポリシーの制限を変更できます。

PS > Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

実行ポリシーの変更
実行ポリシーは、信頼されていないスクリプトからの保護に役立ちます。実行ポリシーを変更すると、about_Execution_Policies
のヘルプ トピック (https://go.microsoft.com/fwlink/?LinkID=135170)
で説明されているセキュリティ上の危険にさらされる可能性があります。実行ポリシーを変更しますか?
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "N"): Y

実行ポリシーの反映を確認します。


PS > Get-ExecutionPolicy
RemoteSigned

この実行ポリシー設定で、ng serve が実行できるようになります。

References

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?