Nodejs+express Building a server

Source: Internet
Author: User

1.Express is a simple and flexible node. JS WEB Application framework that provides a range of powerful features to help you create a variety of Web applications and rich HTTP tools.

Express can be used to quickly build a full-featured website.

2. So using the wxpress frame, you need to first install the Nodejs

3. Global Installation Express-generator
NPM Install Express--save-g
NPM Install Express-generator--save-g

Express is a web framework for NODEJS, which uses express to make it easier to use Nodejs.

Express-generator is the Express application generator, equivalent to express skeleton, into a Web project, using the Express ProjectName command, can quickly build projectname this application directory structure.

4. Start your first express project

Find the folder where you usually do your project. or feel free to find a place, open the file by command CD, or CMD at the path

At the path

Open after input command: Express project name, so create a new project

After installation there will be 3 selection:

Hit Item: CD Expressdemo

Installation: NPM Install

Startup Project: NPM start

To open a project using the editor

Bin: Used for app launch, can set the port number to start on the inside, etc.

/public: Static Resource Directory

/routes: Can be considered a controller directory, routing.

/views:jade template directory, which can be considered a view directory

App.js Program main file

Since the module is not yet in use, it is necessary to enter into the project and create the Node_modules.

Execute command

NPM Install Express

Generate Node_modules File

After the installation number to execute the command NPM start, will error, the prompt to find the corresponding module, this time according to the prompt installation can be

Execute command:

NPM I http-errors--save-g

Nodejs+express Building a server

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.