今天想在vs code的命令框里运行yarn start,因为不想命令框满天飞。
结果发现报错了
yarn : File C:\Program Files\nodejs\yarn.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Poli
cies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ yarn start
+ ~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined
这是因为执行策略的问题造成的,只需要将CurrentUser的ExecutionPolicy改成unrestricted就行了
Set-ExecutionPolicy -Scope CurrentUser Unrestricted
再次执行yarn start,不报错了
Respect!