在Node下创建编译系统主要的做用是方便开发调试文件node
选择 "工具" -> "编译系统" -> '编译新系统', 输入以下内容:工具
{ "cmd": ["node", "$file"], "selector": "source.js" }
Ctrl + S 保存为node.sublime-bulid 便可测试
创建测试文件server.js文件内容以下:ui
const http = require('http'); const hostname = 'localhost'; const port = '3000'; const server = http.createServer((req, res) => { res.writeHead(200, {'content-type': 'text/plain'}); res.end('hello world'); }); server.listen(port, hostname, () => { console.log(`server is running at http://${hostname}:${port}`); });
按快捷键 Ctrl + B 执行文件编译, 输出以下内容则说明Sublime下的Node编译系统创建成功调试
server is running at http://localhost:3000
按Esc键关闭编译框code
小伙伴们在Sublime下创建Node编译系统环境是否是灰尝简单(^-^), 动手试一下吧!server