This article mainly introduces how to set up a Node in Windows 8. js Development Environment tutorial. Install node in win8. js is also relatively simple, but some permissions are relatively troublesome. If you need them, you can refer to the new node. js. Record some processes and check them for future reference. If you have any unclear or incorrect information, please criticize and correct it.
What is Node. js?
I have read some articles on the Internet. My understanding is that the function is similar to apache and can be understood as a server. But the implementation mechanism is different, and the concurrency effect is very good. His goal is to replace the Apache server mechanism.
Now, let's start environment Configuration:
1. Download Node. js
Go to the official website to download, http://www.nodejs.org/download/ select Windows Installer (. msi) Version 64 bit. Here we will find a Windows Binary (.exe), which is an independent Node. js environment terminal. You can download it without installation and use it directly. I suggest you download. msi and install and use it.
2. Install Node. js
Because it is a Win8 system, some problems may occur during installation.
1) Error 2502, Error 2503
We all know that this type of problem is caused by insufficient permissions and can be executed directly with the administrator privilege.
2) The. msi file cannot be executed.
You can right-click cmd, open the terminal as an administrator, and then execute the "msiexec/package node-v0.10.31-x64.msi" installation. All the way to OK.
3) Verify that the installation is successful.
Cmd enters Node. js installation directory, for example, "C: \ cc \ nodejsfolder". In this directory, you will see several executable files, such as node.exe and npm. If you have added the installation Path to the Path, you do not need to enter the installation directory to execute node.
Enter node-v in cmd to view the version;
You can also enter the Node mode and enter "console. log (" Hello world! ");" To check whether the output is normal, as shown in:
4) further verify the Server Function
Create a new js file, such as test. js. The content is as follows:
var http = require("http");http.createServer(function(req, res) { res.writeHead(200, {"Content-Type":"text/html"}); res.write("Node.js"); res.write("Hello World
"); res.end("This is just testing Node working !!!
");}).listen(3000);console.log("HTTP server is listening at port 3000.");
Then run node test. js on the command line, as shown in:
You can open http: // 127.0.0.1: 3000/in the browser to view the output webpage result:
OK. If everything is normal now, the basic functions of Node. js are successfully installed!
However, we often need to use other installation packages, such as express. So, next Let's Talk About npm.
3. Install the npm Module
First, check the npm config configuration: Enter the npm config list command.
Here are some notes about Win8, or what Chinese users need to understand and configure as needed:
1) Create a New npm directory in the C: \ Users \ *** \ AppData \ Roaming \ directory. Otherwise, an error will be reported when npm install is executed.
2) You can run the following two commands to set the proxy. Note that the proxy address is changed to the actual proxy available.
Npm config set proxy = http: // 127.0.0.1: 8087 (this is the default) npm config set proxy = null (this is set to do not use proxy) npm config set registry = http://registry.npmjs.org
3) if an error is reported step by step, it is usually a proxy problem.
4) if it succeeds, the execution of npm install express should be OK.
4. install other required modules. Just run npm install name. Here we will mention that npm supports installing your own defined modules. However, beginners do not need to worry about this.
Now, the Node. js configuration is complete.