Home > Development Tools > sublime > body text

How to build a Node compilation system under Sublime

藏色散人
Release: 2021-03-11 11:44:55
forward
2130 people have browsed it

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"
}
Copy after login

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}`);
});
Copy after login

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
Copy after login

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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template