首页 > 网站 > WEB开发 > 正文

Express4 启航指南

2024-04-27 14:18:49
字体:
来源:转载
供稿:网友

ExPRess4 启航指南

2014-09-24 21:00 by 聂微东, ... 阅读, ... 评论, 收藏, 编辑

  确实有感而发,Nodejs真的发展太快了,这么说的原因有两点:自己去年冬天买了本《了不起的Node.js》,里面介绍Express的版本还是2.x.x;前些天小伙伴买了本《Node.js实战》,结果依赖的Express是3.x.x。尼玛如果安装目前新版的Express4,那么这些书中的例子连项目都无法正常跑起来。

  Nodejs相关的纸版书一上市就已经过时了!

  

  此文的背景是由于俺某天手欠,升级了最新Express V4+后,发现项目不可用了(还好是公司内部的小工具),查找资料后整理了些许总结,介绍如何使用Express4搭建项目。 

  情况差不多就是这样,那么咱们"深入浅出"一把Express项目吧。

  

  如果看官想了解Express 4之前的安装、使用可查看:http://www.cnblogs.com/Darren_code/p/node_express.html

---------------------------分割线 ---------------------------

目录

  1. 建立工程环境
  2. npm安装细节
  3. 全局模式安装的意义
  4. 创建项目
  5. 目录结构
  6. 配置文件之神奇的package.json

建立工程环境

  先介绍下各种环境吧:

  ipZhCJcE+ZS//UFqOqfXuwDGX0tWLYO5/OlE8EsrnEcWHJmRJkhAOUdidPaaRNcRSFJvAs0weMHfrhp9IFA8H6aHB/hqwi9ZE8cnhUvh+twWR7iCfRM6/RlrSLsjb+/aSgtJUFSmKMichiovss+fihKTDaKOjzOiKIsuDqVlZcv0skTm0dcOLosjTxuaH8IijN4kif2LmDV6xYexJCSWxna2c5GnN7c0wJX8q2D3n67tQsItOEsVBLC4gF9kUjnZHblYfpjsps1hM03J2uidHL/C4hCnE7Qcn0zzbI+4KQClc9/c4azlQsqCJwV0/0O5o7/P6ENtIh+YzbN9+gPJnRRTHFUY6x7Vnus2VXRxPmAJPZZZT298gitk42ZqtlvPA7f2+KWxu+ZCdwsWiZQtL/Gxbf+PW81qBBnz8fmstYT8s2jD1ZCBt/H4rHxNRS4axDfROubYNMwSUM23S10+oamuWWNnFADZgKIpjI8exEAOE59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