What to do
The main purpose of establishing a compilation system under Node is to facilitate the development and debugging files
How to establish
Select "Tools" -> "Compilation System" - > 'Compile new system', enter the following content:
{ "cmd": ["node", "$file"], "selector": "source.js" }
Ctrl S Save it as node.sublime-bulid
How to use
Create a test file server.js file with the following content:
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}`); });
Press the shortcut key Ctrl B to execute file compilation. The output of the following content indicates that the Node compilation system under Sublime is established. Success
server is running at http://localhost:3000
Press the Esc key to close the compilation box
Friends, is it easy to establish the Node compilation system environment under Sublime (^ -^), give it a try!