How to play a local service

1. First, download and install node.js, npm

2. Create a new project folder node such as: nodehost; in the current folder to open the terminal, npm init initialization, npm install express --save install express

3. nodehost root directory create a server.js; from the default service address 127.0.0.1, listening port number

Express the require = const ( "Express") 
const = App Express () 
app.use (express.static ( "WWW")) 
app.listen (8080, () => { 
the console.log ( "service enabling port 8080" ) 
})

4. Create a distal www for storing static files as the root of the index.html nodehost

5. Enter the command node server.js Enter in the terminal, you can see the success of the service has been opened

Guess you like

Origin www.cnblogs.com/QianDingwei/p/11031793.html
Recommended