node. js + Express + Mongodb Development Build personal website (i)

Source: Internet
Author: User
Tags install node

First, Node + Express Environment Construction

0, go to node website to download and install node, if you install NPM and node, then install the Global express,-g Global installation

NPM Install Express  –g

1. Then use Express to create the project, Command: Express project name

Initialize a node project note that the default page template here is jade.

Most small projects use the Ejs template, so use Express to create a Ejs template node project with the command EXPRESS-E project name

EXPRESS-E Project Name

2, the following content is created to create a successful

If EXPRESS–V (uppercase) error

There are two possibilities: ① installing node in the second step does not add an environment variable, which can be solved by adding the environment variable to node.

②express 4.x version of the command tool, you need to install a command tool, execute the command "NPM install-g Express-generator" After the completion of the test.

Install dependencies Here's to tell us to go into the project file to introduce a third-party module

How the run the app starts this project

Command as shown

3, below we install the third-party module into the project directory

Install

4. Project Structure

App.js main file

Bin is the startup file

Node_modules for third-party modules

Public is a resource file [frontend]

Routes for routing files [background]

views as view files [front end]

PS: This project is currently an empty project, with a simple example

5, run the example, start the project

NPM start

As for why the NPM Start command, look at Package.json.

Here is the command for the start command and the corresponding boot file, which is the NPM start equivalent to node./BIN/WWW, which is all right to start.

6. Open Bin/www

Here in fact to see or to change the main is the port number

Can artificially modify the port number, currently the default is 3000

7, understand here after we open the URL http://127.0.0.1:3000/or http://localhost:3000/

You can see a simple example.

At this point, Node + Express installation is complete.

Reprint Please specify: http://www.cnblogs.com/zhangmingze/p/4995818.html

node. js + Express + Mongodb Development Build personal website (i)

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.