问题描述:
tsc : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\tsc.ps1,因为在此系统上禁止运行脚本。
ts运行错误.png
PS D:\TypeScript_Study> cd ts
PS D:\TypeScript_Study\ts> cd .\day01\
PS D:\TypeScript_Study\ts\day01> tsc hello.ts
tsc : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\tsc.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ tsc hello.ts
+ ~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
解决
-
以管理员身份打开 Windows PowerShell
PowerShell.png 输入命令 set-ExecutionPolicy RemoteSigned
set-ExecutionPolicy RemoteSigned
输入命令.png
-
输入 Y 即可
输入Y.png -
再次运行 tsc hello.ts
tsc.png