From today on, I will start a topic on node. JS, which is my summary of reading "node: Up and running. The first lesson is about node. js installation, development tools, and how to create our first service: Hello word.
Window platform node. js installation is very simple, everyone to the http://nodejs.org/download the installation file, directly install it.
We recommend that you use webstorm for development tools. The support for multiple node. JS is quite good. You can read this blog post http://www.cnblogs.com/softlover/archive/2012/08/19/2646265.htmlto find out how to install the software.
We use webstorm to create a project named nodejs.
Create a file named helloworld. js under the project. Write code:
var http=require('http');http.createServer(function(req,res){ res.writeHead(200,{'Content-Type':'text/plain'}); res.end('hello\n');}).listen(8124,'127.0.0.1');console.log('Server running at http://127.0.0.1:8124/');
Next, run node. JS, click the Start menu, select all programs, find node. js (x86), and run node. js command prompt ]. Run the following command on the command line:
node d:/workspace/nodejs/helloworld.js
Here, 'node' is the command, and 'd:/workspace/nodejs/helloworld. js' is the file address you created. When you press enter, the following result is displayed, indicating that your code is running normally and the node. js server is running properly.
Or you can directly use the webstorm debugging tool.
Open the browser and enter http: // 127.0.0.1: 8124/to view the running result.
In Windows 7, the command cannot be executed when the Telnet command is used in the Command window. The prompt "'telnet 'is not an internal or external command, or a program or batch file that can be run" is displayed ".
Cause Analysis: Vista and Windows 7 have telnet, but are not installed by default.
Solution: Control Panel | program and function | enable and disable the WINDOWS function, and select Telnet client. Are you sure you want to save it.
Well, today's example ends.