解决vscode“因为在此系统上禁止运行脚本“报错

问题描述:

通过vscode使用powershell的时候报错:

PS E:DesktopcodevscodeVue> vue init webpack demo vue : 无法加载文件 C:UsersAdministratorAppDataRoaming pmvue.ps1, 因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.co m/fwlink/?LinkID=135170 中的 about_Execution_Policies。

解决:

按照提示点击进入官网:

这样介绍:

PowerShell’s execution policy is a safety feature that controls the conditions under which PowerShell loads configuration files and runs scripts. This feature helps prevent the execution of malicious scripts.

PowerShell的执行策略是一个安全特性,它控制PowerShell加载配置文件和运行脚本的条件。该特性有助于防止恶意脚本的执行。

其有几种不同的执行策略,可以到网站详细看,不做介绍。

通过命令查看自己计算机上的策略: Restricted:限制

Windows客户端计算机的默认执行策略。允许单个命令,但不允许脚本。禁止运行所有脚本文件,包括格式化和配置文件(.ps1xml)、模块脚本文件(.psm1)和PowerShell配置文件(.ps1)。

故将策略更改为RemoteSigned(注意:以管理员身份运行)

经验分享 程序员 微信小程序 职场和发展