Home  >  Article  >  Development Tools  >  How to build a Node compilation system under Sublime

How to build a Node compilation system under Sublime

藏色散人
藏色散人forward
2021-03-11 11:44:552128browse

The tutorial column of sublime below will introduce to you how to establish a Node compilation system under Sublime. I hope it will be helpful to friends in need!

How to build a Node compilation system under Sublime

Building a Node compilation system under Sublime

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!

The above is the detailed content of How to build a Node compilation system under Sublime. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete