0
1

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 3 years have passed since last update.

Power Shellでスクリプトファイルを実行できるようにする

Posted at

#はじめに
PowerShellでvueのバージョンを確認しようと思ったら、「このシステムではスクリプトの実行が無効になっているため、ファイルを読み込むことができません。」とでてきて、バージョンを確認することができなかった。

その解決方法をメモしておきます。

#動作環境

  • windows 10 64bit
  • node v16.13.2
  • vpm v8.1.2
  • @vue/cli 4.5.15

#原因
セキュリティー上の対策で用意にスクリプトファイルの実行をできないようにしいるため。ここでスクリプトを実行できるようにします。

##解決方法

PowerShell
Get-ExecutionPolicy

Restrictedと表示されるはずです。これはすべてのスクリプトの実行を禁止している状態です。

次にPowerShellのコンソールを管理者権限で起動してください。
(管理者権限で起動しないとできません)

PowerShell
Set-ExecutionPolicy RemoteSigned

下記のように表示されますので

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

ここでYを押してEnterキーを押します。

これでスクリプトファイルへの実行ができるようになりました。

#まとめ
エラーが起きたらエラーに意味を調べて、解決方法を調べなければ解決方法が分かってもなんでエラーになってるのかどのようなエラーが起きているのかわからないのでしっかりと調べる必要があると思いました。

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?