今天在电脑上安装完 typescript 后,执行 tsc -v 命令查看版本后,报错。
错误提示: tsc : 无法加载文件 ...\npm\tsc.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=13517 0 中的 about_Execution_Policies。
> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined
解决方法:
以 管理员 身份打开 PowerShell !

执行
输入命令 set-ExecutionPolicy RemoteSigned
选择 Y。
查看
> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
验证
tsc -v
# 结果是 Version 3.9.6
验证成功!
参考: https://blog.csdn.net/dujyong/article/details/106359483 https://www.cnblogs.com/huangmuwei/p/12112014.html
来源:oschina
链接:https://my.oschina.net/u/3563169/blog/4339673