Node.js Êǹ¹½¨ÓÚChromeµÄJavaScriptÒýÇæµÄ£¬GoogleµÄä¯ÀÀÆ÷Chrome£¬ÓÐÒ»¸öºÜÊÇ¿ìËÙµÄJavaScriptÒýÇ棬½Ð×öV8¡£Õâ¸öJSÒýÇæ¿ÉÒÔ±»×ÔÁ¦³öÀ´¡£Node.js¾ÍÊǽ¨Ê÷ÔÚV8Ö®Éϵġ£ÕâÒ²ÊÇΪʲôNode.js»áÔËÐеÄÈç´ËÖ®¿ì¡£¶ÔÓÚ¿ª±ÙÕßÀ´Ëµ£¬Óм¸¸öÒæ´¦£º
Äã²»ÐëÒª´ÓÍ·½øÐÞÒ»ÃÅеÄ˵»°£¬Ëü¾ÍÊÇJS¡£ÎÒ¾³£²é¿´ChromeºÍMozillaµÄJSÎĵµ£¬ËûÃÇÍêȫͨÓá£
Node.js °²×°
1¡¢°²×°±àÒë»·¾³£¬>sudo apt-get install g++ c++ curl libssl-dev apache2-utils git-core curl
2¡¢ÏÂÔØNode°²×°°ü£¬>wget http://nodejs.org/dist/node-v0.3.0.tar.gz
3¡¢±àÒë°²×°£¬²½ÖèÈçÏ£º
>./configure //×¢£ºÈç¹û²»ÐèSSL£¬¿É¼ÓÈëÑ¡Ïî-without-ssl
>make
>make install
4¡¢°²×°³É¹¦£¬Ä¬ÈÏ·¾¶Îª£º/usr/local/bin/node£¡
Node.js Ó¦ÓÃ
1¡¢°²×°³É¹¦ºóÏÈд¡°Hello World!¡±¼òµ¥²âÊÔһϣ¬´úÂëÈçÏ£º
Java´úÂë
view plaincopy to clipboardprint?
//filename: app.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8000/');
2¡¢ÔËÐÐ app.js£¬>node app.js£¬ÔÚä¯ÀÀÆ÷ÊäÈëhttp://127.0.0.1:8000/£¬¼´¿É¿´µ½Ð§¹û
3¡¢NodeÌṩÁËһЩ³£ÓõÄAPI£¬¿É²Î¿¼£ºhttp://nodejs.org/api.html
NPM °²×°
³ýNode±¾ÉíÌṩµÄAPIÍ⣬ÏÖÔÚÓв»ÉÙµÚÈý·½Ä£¿é¿É¼«´óµÄÌá¸ß¿ª·¢Ð§ÂÊ£¬È磺WEB¿ò¼Ü-express£¬HTTPÖмä¼þ-connect£¬Ä£°å-ejsµÈ£¬ÎªÁ˹ÜÀíÕâЩģ¿éÎÒÃÇÐèÒª°²×°NPM£¬°²×°¹ý³ÌÈçÏ£º
1¡¢Ê×ÏÈ×¼±¸Ä¿Â¼È¨ÏÞ£¬²»ÒªÒÔROOTÕʺŰ²×°£¬>sudo chown -R $USER /usr/local
fedoraÏ£¬ÏÈÓÃroot¸ü¸ÄȨÏÞ chown -R $USER /usr/local Ö®ºóÍ˳öroot
2¡¢°²×°NPM£¬>curl http://npmjs.org/install.sh | sh
3¡¢Íê³Éºó°²×°µÚÈý·½Ä£¿éÒ²ºÜ¼òµ¥£¬>npm install modules_name£¬°²×°Express£¬>npm install express
×¢£ºÈç¹û°²×°Ä£¿éµÄ¹ý³ÌÖб¨ÓòÃû´íÎóµÄ»°£¬ÇëÇå¿Õ»º´æ >npm cache clean »òÖØÆô¼ÆËã»ú¼´¿É
ÖµµÃ¹Ø×¢µÄ¸üУº
Build
FreeBSD 10 is no longer supported. #22617
child_process
The default value of the windowsHide option has been changed to true. #21316
console
console.countReset() will emit a warning if the timer being reset does not exist. #21649
console.time() will no longer reset a timer if it already exists. #20442
Dependencies
V8 has been updated to 7.0. #22754
fs
The fs.read() method now requires a callback. #22146
The previously deprecated fs.SyncWriteStream utility has been removed.#20735
http
The http, https, and tls modules now use the WHATWG URL parser by default. #20270
General
Use of process.binding() has been deprecated. Userland code using process.binding() should re-evaluate that use and begin migrating. If there are no supported API alternatives, please open an issue in the Node.js GitHub repository so that a suitable alternative may be discussed.
An experimental implementation of queueMicrotask() has been added. #22951
Internal
Windows performance-counter support has been removed. #22485
The --expose-http2 command-line option has been removed. #20887
Timers
Interval timers will be rescheduled even if previous interval threw an error. #20002
nextTick queue will be run after each immediate and timer. #22842
util
The WHATWG TextEncoder and TextDecoder are now globals. #22281
util.inspect() output size is limited to 128 MB by default. #22756
A runtime warning will be emitted when NODE_DEBUG is set for either http or http2. #21914