【问题标题】:Build System for typescript in sublime text 3 is not working崇高文本3中的打字稿构建系统不起作用
【发布时间】:2018-12-15 17:16:20
【问题描述】:

我已经安装了 Sublime Text 3 并尝试为 TypeScript 创建构建系统。以下是我正在使用的代码

{
    "cmd": ["tsc","$file"],
    "file_regex": "(.*\\.ts?)\\s\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(...*?)$",
    "selector": "source.ts",

    "windows": {
        "cmd": ["tsc.cmd", "$file"]
    }
}

{
    "cmd": ["tsc", "-d", "-m", "amd", "--sourcemap", "$file"],
    "file_regex": "(.*\\.ts?)\\s\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(...*?)$",
    "selector": "source.ts",
    "osx": {
       "path": "/usr/local/bin:/opt/local/bin"
    },
    "windows": {
        "cmd": ["tsc", "-d", "-m", "amd", "--sourcemap", "$file"]
    }
}

Getting [WinError 2] 系统找不到指定的文件。 我尝试了构建系统都无法生成相应的 JavaScript 文件。谁可以帮我这个事。提前致谢。

【问题讨论】:

  • tsc 的位置需要在您的系统上PATH
  • 在尝试构建之前是否保存了 TypeScript 代码?

标签: javascript typescript sublimetext3


【解决方案1】:

对于仍在尝试解决此问题的任何人,这就是我所需要的。真正让我感动的是我需要使用tsc.cmd 而不仅仅是tscquiet:true 只是删除了始终显示在输出窗口底部的[Finished in 1.6s]

TypeScript 将文件转换为 javascript,然后必须运行 javascript 文件,所以...

  • 确保您已安装节点 js 并且 node 在您的路径中。
  • 确保您已使用 npm install -g typescript(节点包管理器)安装 TypeScript,并且您的路径中有 tsc
{
    "cmd": ["tsc.cmd", "$file_base_name.ts", "&&", "node", "$file_base_name.js"],
    "selector": "source.ts, source.tsx",
    "quiet": true
}

【讨论】:

    猜你喜欢
    • 2018-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-21
    • 1970-01-01
    • 1970-01-01
    • 2014-03-26
    • 2014-12-03
    相关资源
    最近更新 更多