babel : 无法加载文件 D:\nodejs\node_global\babel.ps1,因为在此系统上禁止运行脚本

babel : 无法加载文件 D:\nodejs\node_global\babel.ps1,因为在此系统上禁止运行脚本

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

在这里插入图片描述
成功!

  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值