NodeJS Sublime文本构建系统

时间:2014-02-08 14:00:02

标签: node.js sublimetext2

我已经安装了Sublime Text的NodeJS插件,它提供了如下所示的NodeJS构建:

{
  "cmd": ["node", "$file"],
  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
  "selector": "source.js",
  "shell":true,
  "encoding": "cp1252",  
  "windows":
    {
        "cmd": ["taskkill /F /IM node.exe & node", "$file"]
    },
  "linux":
    {
        "cmd": ["killall node; node", "$file"]
    }
}

我自己编译了node并找到了/opt/node/v0.10.24。 bin的完整路径为/opt/node/v0.10.24/bin/node

我正在使用包含console.log('Hello World');

的简单文件对此进行测试

运行构建系统时,我得到:

/Users/jviotti/Desktop/test.js: node: command not found
[Finished in 0.0s with exit code 127]

我尝试在构建中添加path,如下所示:

"path": "/opt/node/v0.10.24/bin",

在运行构建时,我得到了:

[Finished in 0.1s]

请注意,未打印控制台日志。我错过了什么?

编辑:这是我使用的NodeJS插件:https://github.com/tanepiper/SublimeText-Nodejs

2 个答案:

答案 0 :(得分:1)

应该这样做..

{
  "cmd": ["node $file"],
  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
  "selector": "source.js",
  "shell": false,
  "encoding": "cp1252",
  "windows":
    {
      "cmd": ["taskkill /F /IM node.exe && node $file"]
    },
  "linux":
    {
        "cmd": ["killall nodejs 2>/dev/null; nodejs $file"] // or node, if built from source
    }
}

答案 1 :(得分:0)

发现问题。评论"shell": true可以解决问题。

相关问题