Nodejs installation and use, Nodejs Installation and Use
1. Download
:
Https://nodejs.org/download/
Installation 2
1. You can directly double-click the win7 system to run it;
2 win8 requires the Administrator permission to run the program. Otherwise, Error 2502 and Error 2503 are reported;
Specific process reference: http://jingyan.baidu.com/article/a3a3f811ee92268da2eb8af2.html
3. Execute the script
1. Open cmd and enter node-v to view the current version.
2. Open cmd and enter console. log ("Hello world! "); The Hello world!
3. Create a new main. js file with the following content:
Function main () {console. log ("Hello world! ");} Main ();
Open cmd and enter "node main. js" to execute the step main. js. You can see that the output is "Hello world!
4. Create an http server
Var http = require ("http"); http. createServer (function (req, res) {res. writehead( 200, {"Content_type": "text/html"}); res. write ("
Run main. js and open the browser and enter: http: // 127.0.0.1: 800/. You can see: