1.node.js development environment Download, but according to their own use of the computer and the operating system used in the actual situation, specifically as follows:
https://nodejs.org/en/download/
2. Test after installation
(1) Use the following command to view the current Node version:
$ node-v
v4.4.3
(2) You can also perform npm-v to verify that the NPM tool is successfully installed with node.
$ npm-v
3.10.10
3. Interactive mode
Open terminal, type node into the command interaction mode, you can enter a code statement immediately after execution and display the results, for example:
$ node
> Console.log (' Hello world! ');
Hello world!
4. Script mode
Here's our first node. JS Program:
(1) Edit the content of Hello.js with Notepad, save it in d:\\, the content is as follows:
Const HTTP = require (' http ');
const hostname = ' 127.0.0.1 ';
Const PORT = 3000;
Const SERVER = Http.createserver ((req, res) = = {
Res.statuscode = 200;
Res.setheader (' Content-type ', ' text/plain ');
Res.end (' Hello world\n ');
});
Server.listen (port, hostname, () = {
Console.log (' Server running at http://${hostname}:${port}/');
});
(2) Open the CMD console, enter node D:\\hello.js, and the console displays the following statement:
Server running at Http://127.0.0.1:3000/
(3) Open the computer or browser and enter Http://127.0.0.1:3000/
It will appear: Hello world.
Construction of NODE,JS development environment