The installation process is basically direct "NEXT" on it. (The installation MSI file for Windows adds the system variable for path directly in the process, and the variable value is your installation path, such as "C:\Program Files\nodejs").
After the installation is complete, you can use CMD (win+r and then enter CMD entry) to test if the installation is successful. Method: Enter node-v under CMD, the version prompt is complete the installation of Nodejs.
The installation of NPM. Since NPM has been integrated with the new version of Nodejs, NPM has been installed as well. You can also use the cmd command line to enter "Npm-v" to test for successful installation. For example, the version prompt will be OK.
The construction of conventional nodejs has been completed so far, so you can enter the "cmd" input "node" into node development mode, enter your Nodejs first sentence: "Hello World"-Input: Console.log (' Hello World ‘)。
①, we will first configure the NPM Global Module storage path and the path of the cache, for example, I would like to put the above two folder in the Nodejs home directory, the Nodejs under the establishment of "Node_global" and "Node_cache" two folders. Such as
②, start cmd, enter
NPM config set prefix "C:\Program files\nodejs\node_global" and NPM config set cache "C:\Program Files\nodejs\node_cache"
③, now let's install a module to try, choose Express this more common module. Also in the cmd command line, enter "NPM Install Express-g" ("-g" This parameter means to be loaded into the global directory, which is said to set the "C:\Program Files\nodejs\node_global" inside. )。 After the installation process in the CMD is finished scrolling, it will prompt "express" where it is installed, the version and its directory structure. Such as
④, close cmd, open the System dialog box, my Computer right-click Properties-Advanced system Settings-advanced-environment variables. Such as
-
⑤, enter the Environment Variables dialog box, create a new" Node_path "under System variables, enter" C:\Program Files \nodejs\node_global\node_modules ". (PS: This step is quite critical.)
2014.4.19 added: Since the default address of module is changed, the above user variables should be changed (the user variable "PATH" is modified to "\ n Program Files\nodejs\node_global\ "), or the use of the module will cause the input command" XXX is not an internal or external command, is not a executable or batch file "error.
⑥, the above steps are OK, we can open the cmd command line again, enter node, enter "require (' Express ')" To test the next node's module global path is configured correctly. The correct CMD will list information about the Express. such as (if the error is generally node_path configuration is wrong, you can check the next step ④⑤)