Mac下配置Sublime的NodeJS开发环境

  1. Sublime安装JavaScript&NodeJS Snippets插件[1]

  2. Tools - Build System - New Build System,输入[1][2]

    {
    "cmd": ["/Users/luohanjie/.nvm/versions/node/v4.2.6/bin/node", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.js",
    "shell":true,
    "encoding": "utf-8",
    "windows":
    {
    "cmd": ["taskkill /F /IM node.exe", ""],
    "cmd": ["node", "$file"]
    },
    "linux":
    {
    "cmd": ["killall node; node", "$file"]
    },
    "osx":
    {
    "cmd": ["killall node; /Users/luohanjie/.nvm/versions/node/v4.2.6/bin/node $file"]
    }
    }

    注意node的绝对地址。然后保存为Nodejs.sublime-build并且选择Tools - Build System - Nodejs

  3. 建立一个新js文件,输入console.log("ok");, 按Control + B,应该会输出:

    No matching processes belonging to you were found
    ok
    [Finished in 0.1s]

  1. http://blog.comingx.com/?p=3041

  2. http://www.hacke2.cn/nodeJS-sublime-3/