![](/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.