nodejs start up

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

Ubuntu
Example install:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm 

It installs current stable Node on the current stable ubuntu.

Synopsis
An example of a web server written with Node which responds with 'Hello World':
var http = require('http'); 
http.createServer(function (request, response) {   response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World\n'); }).listen(8124); 
console.log('Server running at http://127.0.0.1:8124/');

To run the server, put the code into a file called example.js and execute it with the node program

> node example.js
Server running at http://127.0.0.1:8124/
All of the examples in the documentation can be run similarly.

猜你喜欢

转载自lingceng.iteye.com/blog/1692112