Saturday, 15 March 2014

node js 4 install mogodb + create nodejs project

Install mongodb, and install by simply unzip the archive.
Move mongodb to another location and configure this location into environment path:

export MONGODB=/Users/Peter/Documents/dev/mongodb-osx-x86_64-2.4.9

export PATH=$PATH:$MONGODB/bin
after this file is changed run:
source ~/.bash_profile.

create mongodb data folder:
create a folder by: mkdir $MONGODB/data/db

start mogodb by:

mongod -dbpath $MONGODB/data/db/

a tutorial: 

mongoose vs mongojs

------Create project 

Create a node js project with express, then configure this project by package.json:
  "name": "expresstest",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app.js"
  "dependencies": {
    "express"    : "~3.4.4",
    "mongoose"   : "~3.6.2",
    "hjs": "*"

The key part is the dependencies section.  It decides which node models i will use in this project.

Run "npm install" to install models.

create core.js for Angular.js

create html.hjs for the page.

I found Hogan.js and Angular.js conflect. I have solved it by:
app.locals.delimiters = '<% %>';

No comments:

Post a comment