Node. js has gradually warmed up, and many friends have begun to pay attention to it. However, on Windows platforms, cygwin-based installation and configuration environments are required, which can be discouraged by many users. However, it is reported that Microsoft has contacted the node. js official website and I believe it will be improved soon.
If cygwin is not installed, can I build a node. js environment on Windows for trial development? I made a simple test with node. js + Express, which is basically feasible.
The procedure is as follows:
1. Download the node. js official unstable version of Windows executable program:
Http://nodejs.org/#download
I used version 0.5.7 in the test: http://nodejs.org/dist/v0.5.7/node.exe
2. Create a c: \ nodejsdirectory and save node.exe in this directory.
3. Download Express. Because of the dependency, we also need to download: connect, QS, mime, and jade (default express template system. If you are using another template system, you need to download the corresponding system)
Name address test version
---------------------------------------------------------------
Express: https://github.com/visionmedia/express 2.4.3
Connect: https://github.com/senchalabs/connect 1.7.1
QS: https://github.com/visionmedia/node-querystring 0.3.1
Mime: https://github.com/bentomas/node-mime 1.2.4
JADE: https://github.com/visionmedia/jade 0.15.4
4. Create the c: \ nodejs \ node_modules directory, and create the [module] Directory respectively in this directory. Compress the file downloaded in the previous step and copy the file to the [module] Directory.
Node_modules
|-Connect <= CONNECT: lib /*
|-Express <= Express: lib /*
|-Jade <= JADE: lib /*
|-Mime <= MIME: mime. JS & types /*
|-QS <= QS: lib /*
5. Create the following files in the C: \ nodejs \ node_modules directory:
Connect. js
Content: module. Exports = require ('./connect ');
Express. js
Content: module. Exports = require ('./Express ');
Jade. js
Content: module. Exports = require ('./Jade ');
Mime. js
Content: module. Exports = require ('./MIME ');
Qs. js
Content: module. Exports = require ('./Qs/querystring ');
6. Copy the bin/Express file in the downloaded express package to the C: \ nodejs directory and change it to express. js.
7. Modify the Express. js file. The following uses 2.4.3 as an example:
7.1. Modify the mkdir function body
401: exec ('mkdir-p' + path, function (ERR ){
-> Exec ('md '+ path, function (ERR ){
7.2. Modify the mkdir function call
263: mkdir (path + '/public/javascripts ');
-> Mkdir (path + '\ public \ javascripts ');
264: mkdir (path + '/public/images ');
-> Mkdir (path + '\ public \ images ');
265: mkdir (path + '/public/stylesheets', function (){
-> Mkdir (path + '\ public \ stylesheets', function (){
280: mkdir (path + '/view', function (){
-> Mkdir (path + '\ views', function (){
8. Create an Express project:
C: \ nodejs \ node.exe Express. js-s hello
9. c: \ nodejs \ node_modules \ *. * => C: \ nodejs \ Hello \ node_modules \
10. Run and test:
C: \ nodejs \ node.exe Hello \ app. js
Open http: // localhost: 3000 in the browser and view the result.
Now the test is complete.
The following is a test file. In the test file, I also tested express session. You can open http: // localhost: 3000/session in the browser to view the result.
Test File: nodejs.zip