Title
Environment: Windows 8 64bit\node.js v0.10.33
I think it is necessary to say that I have not installed node. JS in the default directory, but rather a custom path
E:\Program\nodejs
I think a lot of the problems I came across were related to this.
OK, and then I'm happy to open node, enter it under CMD
NPM Install-g Express
It is sure to error, the exact mistake I did not remember, Baidu is the next seems to be the problem of the parameter (the beginning do not know what the meaning of this parameter, later only to understand, is loaded into the NODE_GLOABL directory), so I will take-G removed, CD to I want to install the working directory, The installation is successful (specifically, it is only installed in the current working directory). Continue to follow the online tutorial to create an express project, CMD under input
Express Blog
It sure and error, Express is neither internal command nor external command, Baidu found under the original version (my is 4.9.0) did not bring express-generator, that is, you can not use the Express command to create a project, or to yourself under the module, So continue typing in cmd
NPM Install Express-generator
This way you can use the Express command to create a project (note that only in this directory), I created a blog called the project, the next is to start the service, by the way, I added a port monitoring code in the App.js
var function () { console.log (' Listening on port%d ', server.address (). port);});
This does not have to be entered in the CMD. Then enter it under CMD
Node app
It sure enough and error, looked at the next, the lack of modules, the original many modules are not installed, I listed
' Serve-favicon ' \morgan ' \ ' cookie-parser ' Body-parser '
It's easy to put the modules in the way you did before. The Welcome page will be available after you start the service.
This project to be installed here, I would like to say the global module, that is, do not use each project to install the modules, when using the direct call on it. For this version of node, here's how:
Under the node. JS installation directory, create a new two folder, "Node_global" and "Node_cache", and then enter the following code under CMD
NPM config set prefix "E:\Program\nodejs\node_global""E\program\nodejs\node_cache"
Then install the next express,cmd input in it
NPM Install-g Express
The next step is to add the environment variables to the computer properties, add the Node_path in the environment variable, the variable value is E:\Program\nodejs\node_global\node_modules,
If there is no accident, the global module is set up, and then install the module after adding the-G parameter, it will be automatically installed in the Node_global\node_modules directory, the call is very convenient. In order to detect whether it is feasible, you can enter it under node
Require (' Express ')
If you return information about Express, the settings are correct.
node. JS uses Express to build the server (contains a variety of Pit Dad error Resolution)