安装nodejs
安装cnpm
国内npm镜像库,淘宝的cnpm,可以有效的提高下载nodejs包的速度。
npm install -g cnpm --registry=https://registry.npm.taobao.org
安装express
cnpm install express (如果没有权限就加上sudo)
express官网
安装jade
cnpm install jade
jade基本语法和使用方法
安装Express应用生成器
npm install express-generator
新建web项目
express myapp
获得以下目录:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| create : myapp create : myapp/package.json :npm依赖包 create : myapp/app.js :入口文件 create : myapp/public :静态资源文件 create : myapp/public/javascripts create : myapp/public/images create : myapp/routes :路由 create : myapp/routes/index.js create : myapp/routes/users.js create : myapp/public/stylesheets create : myapp/public/stylesheets/style.css create : myapp/views :模板视图文件目录 create : myapp/views/index.jade create : myapp/views/layout.jade create : myapp/views/error.jade create : myapp/bin create : myapp/bin/www :服务启动函数
|
安装第三方js插件包
1 2
| cnpm install -g bower bower install jquery
|
启动服务器
1 2 3 4 5
| 启动这个应用(MacOS 或 Linux 平台): DEBUG=myapp npm start
Windows 平台使用如下命令: set DEBUG=myapp & npm start
|