【问题标题】:How do you troubleshoot sublime text 2 (typescript) build errors?你如何解决 sublime text 2 (typescript) 构建错误?
【发布时间】:2013-01-03 01:54:40
【问题描述】:

我正在使用来自 this question 的 typescript 构建以及 sublime text 2 中的 build-on-save 插件来尝试自动编译 typescript:

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

由于以下错误,它永远不会构建。任何提示?

[Errno 2] No such file or directory
[cmd:  [u'tsc', u'/Users/dbrito/Sites/Prototypes/totem-tracker/client/views/layout.ts']]
[dir:  /Users/dbrito/Sites/Prototypes/totem-tracker/client/views]
[path: /usr/local/bin:/opt/local/bin]
[Finished]

注意:node 和 npm 是使用 homebrew 安装的。 Typescript 是使用npm -g install typescript 安装的。我在 10.8.2 上安装了最新的 xcode 和命令行工具。以下是我的.profile

export PATH="/usr/local/bin:/usr/local/sbin:~/node_modules/.bin:/usr/local/share/npm/bin:/usr/local/Library/Aliases:${PATH}"
export NODE_PATH="/usr/local/lib/node_modules:${NODE_PATH}"

【问题讨论】:

    标签: sublimetext2 typescript


    【解决方案1】:

    我的猜测是它找不到tsc 或您的文件。您可以仔细检查错误中显示的文件是否存在,然后在终端中提供which tsc 的输出?

    它在您的/usr/local/bin 之外吗?尝试删除 osx 路径设置的东西。

    【讨论】:

    • “路径设置的东西”是什么意思。我会假设 tsc 在我的路径中可用,因为 tsc 命令有效。 which tsc 输出 /usr/local/share/npm/bin/tsc,我认为这是标准的全球 npm 位置。
    • 对。您是否在示例代码中看到了“osx”:{“path”:“...”}的那部分?
    • 您告诉 sublime text 仅在这些文件夹中查找 tsc。删除它,我敢打赌它会起作用。如果不是,请替换为返回的路径。
    • 看起来这可能让我更近了一步。现在错误是env: node: No such file or directory [Finished in 0.0s with exit code 127]
    • 听起来 sublime 根本不尊重你的 shell 路径。好吧,尝试保留 osx 路径的东西,但输入路径的实际值。我
    猜你喜欢
    • 2013-01-21
    • 2013-02-16
    • 1970-01-01
    • 2012-11-04
    • 2021-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多