Express4+Angularjs+Bootstrap3环境搭建
- Nodejs安装:http://blog.csdn.net/xuliuzhu/article/details/51866455, 新版本的Nodejs已集成了NPM。
- 安装Git, 配置环境变量: http://blog.csdn.net/xuliuzhu/article/details/51872554
- 全局安装express
npm install -g express
npm install -g express-generator@4
express -V - 创建项目 D:\apps\nodejs-demo
express -e nodejs-demo
cd nodejs-demo && npm install
- 删除views, routes, public, 新建src, src/index.html
npm install -g bower
新建.bowerrc
{
“directory”: “src/lib”
}
新建bower.json
{
“name”: “angular-basic”,
“version”: “0.0.1”,
“dependencies”: {
“angular”: “1.2.29”,
“angular-route”: “~1.2.29”,
“bootstrap”: “^3.3.6”,
“angular-bootstrap”: “0.10.0”
},
“devDependencies”: {}
}
bower install
bower list
var express = require(‘express’);
var path = require(‘path’);
var favicon = require(‘serve-favicon’);
var logger = require(‘morgan’);
var cookieParser = require(‘cookie-parser’);
var bodyParser = require(‘body-parser’);
var ejs = require(‘ejs’);
var app = express();
// view engine setup
app.engine(‘.html’, ejs.__express);
app.set(‘view engine’, ‘html’);
app.use(logger(‘dev’));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, ‘src’)));
// angular启动页
app.get(‘/’, function (req, res) {
res.sendfile(‘src/index.html’);
});
【Express4+Angularjs+Bootstrap3环境搭建】module.exports = app;