前提:windows 系统,你已经安装了 Sublime Text3,电脑已经有 node 环境。

步骤:

  • 下载 sublime 的 nodejs 插件,需是集成 Nodejs 插件到 sublime 中,下载地址:https://github.com/tanepiper/SublimeText-Nodejs
  • 解压 zip 文件, 并重命名文件夹“Nodejs”
  • 打开 sublime,操作”preference” –> “Browse packages”, 打开一个目录,这个目录是众多语言 IDE 插件的存放地。
    *  复制”Nodejs“文件夹到这个目录。 
    *   打开 Nodejs 文件夹,找到文件“Nodejs.sublime-build”, 拖拽到 sublime,显示:        { "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"] } }
  • 需要更改上面标注的地方, 要更改 encoding 为 GB2312 或者 utf8,如果不更改此属性可能导致 build nodejs 代码时终端显示乱码。
  • 要用 sublime 打开文件“Nodejs.sublime-settings” 或者 设置“preference” –》 “package settings” –》 “Nodejs”  –》“setting-default” 打开文件并 更改成: { // save before running commands "save_first": true, // if present, use this command instead of plain "node" // e.g. "/usr/bin/node" or "C:\bin\node.exe" "node_command": /usr/bin/nodejs, // Same for NPM command "npm_command": /usr/bin/npm, // as 'NODE_PATH' environment variable for node runtime "node_path": false, "expert_mode": false, "ouput_to_new_tab": false } 到此,已经配置好了。