I. Introduction of NODEJS
1.Node is a server-side JavaScript interpreter.
The goal of 2.Node is to help programmers build highly scalable applications and write connection codes 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 that node is concerned by developers.
The 3.Node itself runs the Google V8 JavaScript engine , so speed and performance are great, and Node's encapsulation of it also improves its ability to process binary data. As a result, node not only uses V8, but also optimizes it to make it more resilient in a variety of environments.
4. Third-party extensions and modules play an important role in the use of node. NPM, for example, is the module's management tool, which installs various node packages (such as Express,redis, etc.) and publishes the packages it writes for node.
Second, installation
Use homebrew to install under Mac:
1, Installation: Brew install node;
2, version: Node-v; Npm-v;
3. Upgrade Node:brew upgrade node
Third, Hello Word
1. New App.js
var http = require (' http '); Http.createserver (function (req, res) { Res.writehead ($, {' Content-type ': ' Text/plain '}); Res.end (' Hello world\n ');}). Listen (1337, ' 127.0.0.1 '); Console.log (' Server running at http://127.0.0.1:1337/');
2. Terminal: node ~/documents/node/app.js
3, Browser: http://127.0.0.1:1337/View results Nodejs has been installed.
Iv. installation of Express
1,sudo npm install-g Express for global installation.
Express provides project birth function terminal input
NPM Install express-generator-g for global installation
2. Create an Express project
Terminal input EXPRESS-E your project name
-E: For use with Ejs frame Express default to Jade (not recommended for novice use, where project configuration boot appears)
Express project has been created before you run it, be sure to install a dependency package, execute the command npm install
3. Operation
Execute command debug=app./bin/www;
Browser http://127.0.0.1:3000 Viewing results
Nodejs First Acquaintance