1、错误展示
babel : File D:\Program Files\nodejs\node_global\babel.ps1 cannot be loaded because running scripts is d
isabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fw
link/?LinkID=135170.
At line:1 char:1
+ babel --version
+ ~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
2、解决办法
在终端输入下面内容
get-ExecutionPolicy
显示:Restricted #说明是有限制的
改为 set-ExecutionPolicy RemoteSigned,在终端输入下面内容
set-ExecutionPolicy RemoteSigned
然后出错:
set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\She
llIds\Microsoft.PowerShell' is denied. To change the execution policy for the default (LocalMachine) sco
pe, start Windows PowerShell with the "Run as administrator" option. To change the execution policy for
the current user, run "Set-ExecutionPolicy -Scope CurrentUser".
+ set-ExecutionPolicy RemoteSigned
+ CategoryInfo : PermissionDenied: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecu
tionPolicyCommand
根据错误的提示内容,在终端重新输入下面内容
Set-ExecutionPolicy -Scope CurrentUser
点击enter以后,会让你再输入一个东西,直接输入RemoteSigned
使用get-ExecutionPolicy
语句 再次查看
PS D:\project\vscode_project\moduledemo> get-ExecutionPolicy
RemoteSigned
这样就可以了,开始回到原点——查看版本
babel --version
成功!