Automatically install NPM packs for Node.js on Windows Azure Web site

Source: Internet
Author: User
Keywords AZURE NODE.JS AZURE NPM Bag

In my previous article, I described and demonstrated how to Http://www.aliyun.com/zixun/aggregation/13375.html ">node.js and Windows Azure Web Site" (waws) Use NPM package. In that article I used the NPM command to install the packages and then use Git to submit my changes to Windows and sync them to the waws
Git repository. Then Waws will trigger a new deployment hosting my waws git repository application.

One might notice that the NPM package may contain multiple files and may be a bit large. For example, the Azure package, the Windows Azure SDK, is a node.js package, about 6 MB. Another commonly used MVC framework package, "Express", for Node.js, is about 1MB. When I first put a node in Windows
Azure, all nodes must be uploaded to the cloud.

Is it possible for Windows Azure to download and install these packages for us? In this article, I'll show you how to get waws to install all the required packages for us at deployment time.

Let's start the demo

Demos are the most straightforward. Let's create a new waws and copy it to my local disk. Drag folders for Windows to git so that we can submit and send them.

Then open the Command window and install a package in our code folder. We said I wanted to install "express".

Then create a new Node.js file named "Server.js" and paste the following code.

var express = require ("Express"); var app = Express (); App.get ("/", Function (req, res) {res.send ("Hello node.js and Express.");} ); Console.log ("Web creator opened.");  App.listen (Process.env.PORT);

If we switch to Windows Git now, we'll find out that he detected changes we made, including all the files under the "Server.js" and "Node_modules" folders. We need to upload only our source code, but this huge package file must also be uploaded. Now I'll show you how to exclude it and let Windows Azure install the package on the cloud.

First we need to add a special file called ". Gitignore". Since this file contains only the extension, it does not seem to be added directly from the file browser. So we need to add it from the command line. Navigate to the folder of the local repository and execute the following command to create an empty folder named ". Gitignore". If the command window requires input, just press the ENTER key.

echo > Gitignore

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.