报错信息:
PS E:\Ctrip\TS\01_TypeScript> tsc .\test1.ts
tsc : 无法加载文件 P:\Node.js\node_global\tsc.ps1,因为在此系统上禁止运行脚本。有关详细信息
,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ tsc .\test1.ts
+ ~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
解决方法:
- 搜索windowsPowerShell,选择以管理员身份运行
- 输入命令set-ExecutionPolicy RemoteSigned,然后输入Y
结果:
PS E:\Ctrip\TS\01_TypeScript> tsc -V
Version 5.0.2
PS E:\Ctrip\TS\01_TypeScript> tsc .\test1.ts
PS E:\Ctrip\TS\01_TypeScript>