How to install the Node.js module on Windows _javascript tips

Source: Internet
Author: User
Tags mkdir
However, there are reports that Microsoft has contacted Node.js, and that there will be improvements soon.
So without installing Cygwin, can you build a node.js environment on Windows to test development? I made a simple test with Node.js + Express, which is basically feasible.
The steps are as follows:

1. Download Node.js official non-stable version of Windows executable program:
http://nodejs.org/#download
I used the 0.5.7 version in the experiment: Http://nodejs.org/dist/v0.5.7/node.exe

2. Create the C:\nodejs directory and save the Node.exe in this directory

3. Download Express. Because of dependencies, we also need to download: Connect, QS, mime and Jade (express default Template system. If you use another template system, you need to download the corresponding system.
Name Address Trial 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 in this directory separately. Then compress the files that were downloaded in the previous step and copy the related files to the [Module] directory.
Node_modules
|-Connect <= connect:lib/*
|-Express <= express:lib/*
|-Jade <= jade:lib/*
|-MIME <= mime:mime.js & types/*
|-QS <= qs:lib/*

5. In the C:\nodejs\node_modules directory, create the following files separately:
Connect.js
Content: Module.exports = require ('./connect/connect ');
Express.js
Content: Module.exports = require ('./express/express ');
Jade.js
Content: Module.exports = require ('./jade/jade ');
Mime.js
Content: Module.exports = require ('./mime/mime ');
Qs.js
Content: Module.exports = require ('./qs/querystring ');

6. Copy the bin/express file from the downloaded Express compression package to the C:\nodejs directory and rename it to Express.js

7. To modify the Express.js file, take the following 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 + '/views ', function () {
->mkdir (path + ' \\views ', function () {

8. Create a 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 in Browser: http://localhost:3000, view results.

This test is complete.
The test file is given below, and I tested the express session in the test file. You can open it in a browser: Http://localhost:3000/session to see the results.

Test documents: Nodejs.rar
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.