First Node. Js
- 2020-03-30 03:49:43
- OfStack
1. What is node. js
[1]Node is a server side JavaScript interpreter, but really think JavaScript good students can learn Node easily, then you are wrong, summary: water is not deep I do not know, but it is not shallow.
[2]Node's goal is to help programmers build highly scalable applications, writing connection code that can handle tens of thousands of simultaneous connections to a physical machine. Dealing with high concurrency and asynchronous I/O is one of the reasons Node has caught developers' attention.
[3] Node itself runs Google's V8 JavaScript engine, so the speed and performance are excellent, just look at chrome, and Node encapsulates it while improving its ability to handle binary data. Therefore, Node not only simply USES V8, but also optimizes it to make it more powerful in a variety of environments.
[4] third-party extensions and modules play an important role in the use of Node. The following is also an introduction to downloading NPM. NPM is the module management tool, which is used to install various Node packages (such as express, redis, etc.) and release the packages written for Node.
2. Node. js installation
[1] all you need to do is download and install the Windows platform
[2] Linux platform through:
wget http://nodejs.org/dist/v0.6.1/node-v0.10.31.tar.gz
tar zxvf node-v0.10.31.tar.gz
cd node-v0.10.31
./configure
3. Simple cases
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Worldn');
}).listen(3000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3000/');
You can view "Hello World" through browser access.