1. build a app.js file
const http = require('http'); const chalk = require('chalk'); const conf = require('./config/defaultConfig') const server = http.createServer((req,res)=>{ res.statusCode = 200; res.setHeader('Content-Type','text-plain'); res.end("hello http!") }) server.listen(conf.port,conf.hostsname,()=>{ //conf.port:3000(端口号,随便写) conf.hostname:127.0.0.1 const addr = `http://${conf.hostname}:${conf.port}`; console.info(`Server started at ${chalk.green(addr)}`) })
2. At this terminal node app.js, you can start the service. But not hot update each modification, we can supervise the installation of a global
3. At this time no need to use node app.js started, you can use Supervisor app.js start
npm i -g supervise