Preparations for the development of WeChat public account interfaces for learning node js

Source: Internet
Author: User
Tags install node

Xu: Due to work needs, I recently started to learn Node. js. I 've heard about node. js before, but I haven't actually seen it, so I have to google it. As for what node. js is, what can I do, I won't say much about the advantages or disadvantages, because I can't say it either.

Note: Because the operating system platform is a windows environment, this series of development tests are based on windows systems. (Win7) system;

I. preparations:

Install node js

1. Go to the node js official website and select INSERTALL to download the xxxxx 86.msi version. This version will install node js and npm;

2. After the download is complete, follow the prompts to install it. The environment variables will be set by yourself.

3. Check whether node. js is successfully installed. Open the cmd command window and enter node-v, or press Enter. If npm-v is successfully installed, you can see the version number of the currently installed node js or npm. For example:



If you want to build a WEB program, you must install the express framework module.

Install express <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + MaGitPK/qsP8we60sL/fingerprint + pgltzybzcm9 "http://www.2cto.com/uploadfile/Collfiles/20140509/2014050909132231.jpg" alt = "\">

After the installation is successful, follow these steps.


Then we can use the express command to create the item directory. If express is not an internal command error, check whether express is in the C: \ Users \ Administrator \ AppData \ Roaming \ npm directory. cmd file, such as: if not, npm install express-generator-g will have express. cmd file;



Switch to the node js installation directory and execute express-e webtest to create the webtest item directory.-e indicates that the template uses ejs



Open the webtest project directory and open the package. json file. The content is as follows:

{
"Name": "application-name", application name
"Version": "0.0.1", version
"Private": true,
"Scripts ":{
"Start": "node./bin/www" Startup File
},
"Dependencies": {the dependency on a module is required here. Module name: Version Number
"Express ":"~ 4.0.0 ",
"Static-favicon ":"~ 1.0.0 ",
"Morgan ":"~ 1.0.0 ",
"Cookie-parser ":"~ 1.0.1 ",
"Body-parser ":"~ 1.0.0 ",
"Debug ":"~ 0.7.4 ",
"Ejs ":"~ 0.8.5"
}
}


Run the npm install command to install the module required by the webtest project, that is, the content of the package. json File above;

In this way, we can start node js development.

I will write it here today. The next article will write about the file directory structure of the webtest project and the node js routing and other content.


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.