In May September, I wrote an article about how to manually manage Node. js Modules on the Windows platform [install the Node. js module on Windows]. At that time, on the one hand, I had limited understanding of Node. js, and it was really troublesome to deploy Node. js on the Windows platform, so I chose to manually manage the Node. js module.
Now the situation has changed significantly. On the one hand, Node. js has completed the transformation of the port-based network model on the Windows platform, and on the other hand, NPM can work well on the Windows platform. Therefore, it is easier to deploy Node. js on the Windows platform. The following describes my operation steps.
1. Download the official Node. js program for Windows:
Http://nodejs.org/#download
Starting from 0.6.1, Node. js provides two installation methods on Windows. One is the. MSI installation file and the other is the. EXE executable file.
I selected the. EXE file. In addition to copying node.exe to the C: \ Program File (x86) \ directory and modifying the system Path, the. msiinstallation File has no other functions.
My version is 0.6.2: http://nodejs.org/dist/v0.6.2/node.exe
2. Create the D: \ nodejsdirectory and save node.exe in this directory. Add "D: \ nodejs" to the PATH of the system environment variable to facilitate node application execution at any location.
3. Download npm source code:
Https://github.com/isaacs/npm/tags
Note that at the time of writing this article, the latest npm version is 1.0.106, but this latest version and 1.0.105 have problems on the Windows platform. So I chose to install version 1.0.104:
Https://github.com/isaacs/npm/zipball/v1.0.104
4. decompress the npm source code to the D: \ npmjs directory.
In the Command Prompt window, perform the following operations to complete npm installation:
- D:\>cd npmjs
- D:\npmjs>node cli.js install -gf
In addition:
- Node cli. js install npm-gf // you can install the latest NPM version.
- Node cli. js install npm@1.0.105-gf // you can install the specified version of NPM
The above two methods are downloaded and installed from the code library through the network, but the code library generally only keeps the last two versions.
5. After NPM is installed, add "D: \ nodejs \ node_modules" to the system environment variable NODE_PATH.
6. Install express:
- Npm install express-g // install the latest version of express
- Npm install express@2.5.0 // install a specified version of express
-
- Npm remove express-g // Delete express
For more npm usage, refer to npm Official Website: http://npmjs.org
Now the deployment is complete.
- D: \> node-v
- V0.6.2
-
- D: \> npm-v
- . 0.104
-
- D: \> express-v
- . 5.1
-
- D: \> express hello // create an exrpess Project
- D: \> cd hello
- D: \ hello> node app. js // start
Open http: // localhost: 3000 in the browser and view the result.
Supplement: The npm source code package does not contain dependency modules. For easy installation, download is provided here:
Http://files.cnblogs.com/seanlv/node_modules.zip
After downloading, overwrite the node_modules folder in the npm directory.
Original article: http://www.cnblogs.com/seanlv/archive/2011/11/22/2258716.html