TS tsc : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\tsc.ps1,因为在此系统上禁止运行脚本。

问题描述:

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
解决
  1. 以管理员身份打开 Windows PowerShell


    PowerShell.png
  2. 输入命令 set-ExecutionPolicy RemoteSigned

set-ExecutionPolicy RemoteSigned
输入命令.png
  1. 输入 Y 即可


    输入Y.png
  2. 再次运行 tsc hello.ts


    tsc.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容