顯示具有 Express 標籤的文章。 顯示所有文章
顯示具有 Express 標籤的文章。 顯示所有文章
node.js

Node.js Create Simpleness Blog


I follow this example to implemented blog.

Refer to Creating simple blog with Node.js (express and mongodb)

1.Create Express


First let's install express

If you don't have install 'express' you must setinng on this step.

npm install -g express

The -g flag means is your express will be installing globally on your system

Useing commamd to create blog project
$ express blog-express

  create : blog-express
  create : blog-express/package.json
  create : blog-express/app.js
  create : blog-express/public
  create : blog-express/public/javascripts
  create : blog-express/public/images
  create : blog-express/public/stylesheets
  create : blog-express/public/stylesheets/style.css
  create : blog-express/routes
  create : blog-express/routes/index.js
  create : blog-express/routes/user.js
  create : blog-express/views
  create : blog-express/views/layout.jade
  create : blog-express/views/index.jade
Command is auto create package.json so we will just following command execution:
  install dependencies:
  $ cd blog-express && npm install
Then we can test whether the installation is successful
  run the app:
  $ node app

Opne browser and link to localhost:3000 test your app is work!

If the app is Correct Work you will see the following picture

Imgur

node.js

Express install Guide and Use


Refer to Express Guide

Getting Started


Install express

npm install -g express

After the installation is complete you can use the npm info express version to confirm express.

Example1:

The sample was install for individual project under express

Create a project folder
$ mkdir helloworld
You will need a "package.json" file in the project folder, this file contains "project name" "description" "project version" and "project dependencies conten".
$ vim package.json
 {
  "name": "helloworld",
  "description": "helloworld",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
   "express": "3.x"
  }
 }
Save package.json and starting install express from the project
$ npm install

After the installation is complete the following information will be shown

express@3.4.8 node_modules/express
├── merge-descriptors@0.0.1
├── methods@0.1.0
├── cookie-signature@1.0.1
├── range-parser@0.0.4
├── fresh@0.2.0
├── debug@0.7.4
├── buffer-crc32@0.2.1
├── cookie@0.1.0
├── mkdirp@0.3.5
├── commander@1.3.2 (keypress@0.1.0)

├── send@0.1.4 (mime@1.2.11)
└── connect@2.12.0 (uid2@0.0.3, pause@0.0.1, bytes@0.2.1,     raw-body@1.1.2, qs@0.6.6, batch@0.5.0, negotiator@0.3.0,    multiparty@2.2.0)

Example2:

The sample was install express on Global system

$ npm install -g express