在Windows使用NodeJs和Web Framework:Express开发网站
以下[*]开头注明都在命令行【CMD】工具中执行。【通过Windows操作系统的[运行]键入cmd打开命令行窗口】
必备条件:
1.在Windows操作系统上安装NodeJs和Npm[参考文章:]
2.安装Express框架:
*.npm install -g express【安装Express框架】
创建Web网站:
1.【创建应用:betterlife】
*.express D:\nodejs\betterlife && D:\nodejs\betterlife
2.安装Express应用运行必需【Dependency】模块
*.npm install
3.运行服务器
*.node app
一般默认会启动3000端口
到这一步应该就可以在电脑的浏览器里看到该页面。
-------------------------前进前进前进进-----------------------------------
1.安装Nodemon,修改所见即所得,无需重启Node服务器
*.npm install -g nodemon
2.在Github上下载一个Node应用:https://github.com/shapeshed/express_example
3.解决中文乱码的问题
将下载包里后缀名为jade的文件另存为Utf8,这样修改内容为中文,也不会有中文乱码的问题
4.寻找云部署站点[免费]:
Heroku:https://devcenter.heroku.com/articles/quickstart
5.以下是我部署成功的NodeJs站点
采用Heroku部署成功:
URL:http://nodejsapp.herokuapp.com/
Git:git@heroku.com:nodejsapp.git
参考文献:
Web Framework: Express:https://github.com/visionmedia/express
Express参考手册:http://expressjs.com/guide.html
Creating a Basic Site With node.js and Express:
http://shapeshed.com/creating-a-basic-site-with-node-and-express/