Mac下配置Sublime的NodeJS开发环境

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

  2. Tools - Build System - New Build System,输入23

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    {
    "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,应该会输出:

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


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

  2. http://blog.comingx.com/?p=3041↩︎

  3. http://www.hacke2.cn/nodeJS-sublime-3/↩︎