![](/img/trans.png)
[英]TSC/Rollup: how to pipe TSC output into Rollup without TSC emitting files?
[英]tsc : File C:\Program Files\nodejs\tsc.ps1 cannot be loaded because running scripts is disabled on this system
我正在尝试为file.ts
运行命令tsc
以将此代码编译为js
,但我发现以下错误:
tsc : File C:\Program Files\nodejs\tsc.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ tsc test.ts
+ ~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
这是我的Editor
的屏幕截图:
任何人都知道我该如何解决这个错误?
PowerShell
有一些执行策略,告诉PS
如果用户尝试执行某些代码或脚本该怎么做。
如果执行策略是Undefined (大多数情况下),则应用的策略是Restricted 。
正如Restricted Policy
中定义的那样,所有脚本文件的执行都被阻止。
阻止运行所有脚本文件,包括格式化和配置文件 (
.ps1xml
)、模块脚本文件 (.psm1
) 和 PowerShell 配置文件 (.ps1
)。
您可以按照此处的建议在PS
中运行此命令来检查您当前的执行策略。
Get-ExecutionPolicy
或者
Get-ExecutionPolicy -List
您可以更改执行策略,例如
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser
记住
In Windows Vista and later versions of Windows, to run commands that change the execution policy for the local computer, LocalMachine scope, start
PowerShell
with the Run as administrator option.
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.