Node.js uses the express framework to build a small web site (__div)

Source: Internet
Author: User
Tags sublime text node inspector


1.ejs Module

In the Express version of my download, the default is to use the jade template, Jade Style, although concise, but I am not accustomed to, after all, familiar with the traditional HTML style, so I recommend Ejs style, it and HTML style is basically consistent, easy to start.

It is best to execute the NMP install Ejs in the Node.exe directory so that the Ejs module can be placed in the default project module Node_module.

After downloading, you need to modify the. JSON configuration file, as follows:

"Dependencies": {
"Express": "3.10.4",
"Ejs": "*"
}

Finally, modify the engine configuration in App.js to: App.set (' View engine ', ' Ejs ');


2.express-partials Module

The module can detach the variables in the engine template again, such as the following tags in the A.ejs <ul id= "items1" ><%-partial (' items1 ', data1)%></ul>, You can re-establish the Item1.ejs to reset the data1 variables as follows:

<li>
	<%= items1%>
	<a href= "/del/<%= items1%>" >
		
	</a>
	<a href="/update/<%= items1%> ">
		
	</a>
	<a href= "/add" >
		
	</a>
	< Button onclick= "Showupdatemodal (<%= items1%>)" > Edit </button>

This A.EJS data variable has a partial feature and is separated into a separate UI page for easy and flexible display.

Installation method: NMP Install Express-partials


3. Debugging

There are three ways to debug Nodejs currently known:

A. Download the VS2012 Nodejs plugin, debug with VS2012

B. Using WebForm

C. Download the Node-inspector module.

I have been tested a and c,vs I do not say, must be strong, the disadvantage is that the feeling on the point of being overqualified, write a nodejs just, the start vs a bit too much card. So I used the C way, of course, in advance also need a text editor, Nodejs text Editing Tool when the sublime text, very cool, complete the explosion nodepad++ and UE, and it can also edit other languages.

The use of Node-inspector debugging methods are as follows:

A. First NODE-DEBUG-BRK app.js
B. Then open a new window to start Node-inspector
Appears as follows:
Node Inspector v0.5.0
Info-socket.io started
Visit http://127.0.0.1:8080/debug?port=5858 to start debugging.
Debug input in Browser: http://127.0.0.1:8080/debug?port=5858

No surprises will be in the browser to see the source code debugging interface, PS: It is best to use Google Browser, do not explain.


4. Other

Finally, we recommend a module supervisor, it is best to install NPM INSTALL-G supervisor globally, so that when you start the program (such as App.js) you can supervisor app to start, so it will monitor your code, and automatically restart the service once the code has been modified. No manual, debugging is convenient.

There are many other modules, here is not said, you can go to the official website www.nodejs.org module tags to search, there are a lot of good resources. Originally wanted to build a Web site, found it takes a lot of time to make it clear that all the information of the company can not be copied, it is difficult to write a blog, so record all the tools. Finally, attach some reference materials, passing by can be collected:

Nodejs Learning Materials:
Official website: http://nodejs.org/
Tutorials: http://www.w3cschool.cc/nodejs/nodejs-fs.html
Nodejs Connection sqlserver;http://www.cnblogs.com/joylee/archive/2013/02/05/msnodesql.html
Nodejs official tutorial; http:// azure.microsoft.com/en-us/documentation/articles/sql-database-nodejs-how-to-use/
Nodejs Package Overview: http:// blog.csdn.net/chszs/article/details/8868086
Nodejs Installation and configuration under Windows System: http://blog.csdn.net/freshlover/article/ details/12691031
Jade Syntax:
http://www.cnblogs.com/fullhouse/archive/2011/07/18/2109938.html
https:// Www.npmjs.org/package/jade
http://hi.baidu.com/tang_guangyao/item/6ca7d227cd1406d851fd8762
Ejs use: http:// sunnyhl.iteye.com/blog/1985539
Nodejs Operation cookie:http://www.cnblogs.com/rubylouvre/archive/2012/08/19/2645644. HTML

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.