Yesterday just started learning node. js, some tutorials on the web are not very clear, so summarize my experience.
1. Install.
Installation is omitted, go to the official website to download install a bit just fine. After the installation is complete, open cmd and enter "path" to see if node. js and NPM are configured in the PATH environment. Shown below, indicating that it has been configured.
Check the node. js version, enter "Node--version" or "node-v"
2. Install the module.
NPM is the package management tool that is installed with node. js. It was installed at the same time that node. JS was installed.
Check the node. JS version and enter "NPM--version" or "npm-v":
To install the module, enter:
NPM Install Coffee-script-g
NPM Install Jade-g
NPM Install Mysql-g
CMD shows that when the installation is complete, you can open the NPM catalog C:\Users\momo\AppData\Roaming\npm\node_modules to view it.
3. Start node. js
3.1 Node installation directory, open Node.exe.
3.2 Open cmd and enter node. Consistent with the above effect.
4.note.js Running JS file
The
Creates a new test.js in a directory with the following contents:
var http = require (' http ' function // send HTTP header // HTTP Status value: 200:ok // content type: Text/plain response.writehead ($, {' Content-type ': ' Text/plain ' // send response data "Hello World" Response.End (' Hello world\n ' 8888 // terminal prints the following information Console.log (' Server running at http://127.0.0.1:8888/');
Open cmd and switch to the Test.js directory:
Open Browser, type: http://127.0.0.1:8888/
Show Hello World:
Hope to be helpful to everyone.
Widows node. JS Environment Construction and Operation JS