Last active
August 29, 2015 14:01
-
-
Save leeyinglee/00f8927624cf9fc5c1ca to your computer and use it in GitHub Desktop.
从零开始Nodejs Express开发
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. 首先从官网下载Node.js并安装(http://nodejs.org/) | |
➜ ~ node -v | |
v0.10.28 | |
➜ ~ npm -v | |
1.4.9 | |
2. express安装 | |
➜ ~ sudo npm install -g express-generator | |
版本 | |
➜ ~ express -V (注意:这里的V必须大写) | |
4.2.0 | |
3. 创建nodejs项目 | |
➜ ~ cd node | |
➜ node express -e nodejs (-e/ejs -jade/jade) | |
create : nodejs | |
create : nodejs/package.json | |
create : nodejs/app.js | |
create : nodejs/public | |
create : nodejs/public/javascripts | |
create : nodejs/public/images | |
create : nodejs/routes | |
create : nodejs/routes/index.js | |
create : nodejs/routes/users.js | |
create : nodejs/public/stylesheets | |
create : nodejs/public/stylesheets/style.css | |
create : nodejs/views | |
create : nodejs/views/index.ejs | |
create : nodejs/views/error.ejs | |
create : nodejs/bin | |
create : nodejs/bin/www | |
install dependencies: | |
$ cd nodejs && npm install | |
run the app: | |
$ DEBUG=nodejs ./bin/www | |
4. 下载并安装依赖包 | |
➜ node cd nodejs && npm install | |
5. 启动项目 | |
➜ nodejs npm start | |
> [email protected] start /Users/gene/Node/nodejs | |
> node ./bin/www | |
ok!now you can go and open your site. Have a look! | |
node app.js 应该也可以启动项目,but it's not work in my project. i don't know why... | |
参考 http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/ | |
Thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment