javascript was generally used before web development, but because of the emergence of node.js, it is no longer a complex thing to develop back-end programs with JavaScript. In node.js, the JS engine comes from the chrome V8 browser, with the additional tool code developed by node.js, which itself is very easy to use and very efficient. In addition, node.js has the same tool as PIP NPM. NPM can install third party software easily, which brings great convenience to our development. On the weekend, it's really good to learn about node.js.

1, node.js

sudo apt-get install nodejs

2 installation, npm

sudo apt-get install npm

3 installed, try to install express

npm install express --save

4 framework, to write the most simple hello.js, using nodejs hello.js to implement

console.log ('Hello world')

5, a more complex http

 const HTTP server code (= require'http'); const hostname =''const; port = 3000; const = http.createServer (server (req, RES) {=> res.statusCode = 200; res.setHeader ('Content-Type','text/plain'); res.end ('Hello Worldn');}); server.listen (port, hostname, (=>); console.log (`Server running at {http://${hostname}: ${port}/`) 


6;}), the use of express development http

 var server 

express = require ('express'); VAR (APP = express); app.get (' / ', function (req, RES) {res.send} ('Hello World'); VAR server = app.listen (8081), function (VaR) {host = server.address (VaR port server.address (.Address) = console.log (.Port) access URL is http://%s:%s, host, port)


}) left to do

node.js there are a lot of framework, there are many third party libraries, the project is very easy to use, welcome to a lot of use, a lot of practice.

This paper fixed link: | Script Home | +Copy Link

Article reprint please specify:A summary of the basic knowledge of node.js | Script Home

You may also be interested in these articles!