Similar in design to Event Machine in Ruby, Twisted in Python or React in Php
1: multiple threads for file and network events
$ bash hello-world.sh
$ java hello-world.jar
$ php hello-world.php
$ python hello-world.py
$ ruby hello-world.rb
$ node hello-world.js
hello-world.js
console.log('Hello World!');
Hello World!
hello-www-world.js
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.send('Hello World!\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
Server running at http://127.0.0.1:1337/
Hello World!
var http = require('http');
requireassert, buffer, childprocess, cluster, console, constants, crypto, debugger, dgram, dns, domain, events, freelist, fs, http, https, linklist, module, net, os, path, punycode, querystring, readline, repl, stream, stringdecoder, sys, timers, tls, tty, url, util, vm, zlib,
https://github.com/joyent/node/tree/master/lib
npm <command> [args]
$ npm install ________
$ npm install express
hello-www-world-express.js
var express, app, server;
express = require('express');
app = express();
app.get('/hello-world.txt', function(request, response){
response.send('Hello World!');
});
server = app.listen(1337, function() {
console.log('Listening on port %d', server.address().port);
});
Server running at http://127.0.0.1:1337/
Cannot GET /
hello-www-world-express.js
var express, app, server;
express = require('express');
app = express();
app.get('/hello-world.txt', function(request, response){
response.send('Hello World!');
});
server = app.listen(1337, function() {
console.log('Listening on port %d', server.address().port);
});
Hello World!
|
|
|
|
| Grunt | JsHint | CssLint | Bower |
|---|---|---|---|
| The JavaScript Task Runner | Detects errors and problems in JavaScript code | Points out problems with your CSS code | A package manager for the web |