Node+express+ejs Front-end project setup on Mac

Source: Internet
Author: User
Tags install node

Record the process of building a front-end Web project on my Mac


1. Install node

Find the node version you need to install on the Web: Http://www.oschina.net/news/60538/node-0-10-37-maintain, my version is node-0-10-37.

Macintosh Installer (Universal): http://nodejs.org/dist/v0.10.37/node-v0.10.37.pkg

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/13/wKioL1XdOiPTeh0tAABjEQc1GPk955.jpg "title=" Bf46b187-2977-4b7a-bc18-a6f045f009d0.png "alt=" Wkiol1xdoipteh0taabjeqc1gpk955.jpg "/>

Click on the icon and the next step is done.

Open the command line to see if the installation was successful:

Input: Node-v

Display: v0.10.37

Input: Npm-v

Display: 1.4.28


(The above content step by step, I was fixed a version, to prevent different versions of the code will conflict.) )



2. Install Express

First select a project location, such as WWW folder, CD www/(project name) into the file

OK, let's start the order.

NPM Install Express

Express

sudo   npm Install

Install Express failed to trysudo 管理员权限

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/17/wKiom1XdPo_SxMMCAAGZdPYULLc312.jpg "title=" Untitled -1.jpg "alt=" Wkiom1xdpo_sxmmcaagzdpyullc312.jpg "/>


3, install Ejs replace the default jade

npm Install Ejs


4. JS code ejs change to HTML suffix

Editor opens App.js

It

App.set (' Views ', Path.join (__dirname, ' views ')); App.set (' View engine ', ' Jade ');

Replace

App.set (' Views ', Path.join (__dirname, ' views ')), App.engine ('. html ', require (' Ejs '). __express) App.set (' View engine ', ' HTML ');


Delete the template file of the jade suffix in the Views folder

Inside you can now create your own index.html files!

<! DOCTYPE html>


There is one place to pay attention. The public folder needs to add a favicon.ico file name of the picture files, is the site's logo, or run the project will be error.

ico Image production URL

http://www.ico.la/


You can now tap NPM start on the project to run the Web page http://localhost:3000/

This article is from the "Angry Chick" blog, make sure to keep this source http://yutao.blog.51cto.com/5139912/1688423

Node+express+ejs Front-end project setup on Mac

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.