Express application generator的使用
首先拷贝express官网的一篇文章:
(http://expressjs.com/en/starter/generator.html )
|
Express application generator Use the application generator tool, express-generator, to quickly create an application skeleton. The express-generator package installs the express command-line tool. Use the following command to do so: $ npm install express-generator -g Display the command options with the -h option: $ express -h
Usage: express [options] [dir]
Options:
-h, --help output usage information --version output the version number -e, --ejs add ejs engine support --hbs add handlebars engine support --pug add pug engine support -H, --hogan add hogan.js engine support -v, --view <engine> add view <engine> support (ejs|hbs|hjs|jade|pug|twig|vash) (defaults to jade) -c, --css <engine> add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css) --git add .gitignore -f, --force force on non-empty directory For example, the following creates an Express app named myapp. The app will be created in a folder named myapp in the current working directory and the view engine will be set to Pug: $ express --view=pug myapp
create : myapp create : myapp/package.json 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.pug create : myapp/views/layout.pug create : myapp/views/error.pug create : myapp/bin create : myapp/bin/www Then install dependencies: $ cd myapp $ npm install On MacOS or Linux, run the app with this command: $ DEBUG=myapp:* npm start On Windows, use this command: > set DEBUG=myapp:* & npm start Then load http://localhost:3000/ in your browser to access the app. The generated app has the following directory structure: . ├── app.js ├── bin │ └── www ├── package.json ├── public │ ├── images │ ├── javascripts │ └── stylesheets │ └── style.css ├── routes │ ├── index.js │ └── users.js └── views ├── error.pug ├── index.pug └── layout.pug
7 directories, 9 files |
这里需要注意的是:
- 需要把npm的路径加入到系统的环境变量中去。不然的话即使安装了express-generator,命令行也无法识别express命令。加入环境变量后要重启命令行才可以。
Npm的路径通常为c:\users\<user name>\appdata\roaming\npm
- 然后按照上面文章中的步骤执行即可, 里面的—view可以选择jade,这个我比较熟悉。
Express application generator的使用的更多相关文章
- [转] Creating a Simple RESTful Web App with Node.js, Express, and MongoDB
You can find/fork the sample project on GitHub Hey! This and all my other tutorials will soon be mov ...
- 基于express框架的应用程序骨架生成器介绍
作者:zhanhailiang 日期:2014-11-09 本文将介绍怎样使用express-generator工具高速生成基于express框架的应用程序骨架: 1. 安装express-gener ...
- Moving to Express 4
http://expressjs.com/guide/migrating-4.html Moving to Express 4 Overview Express 4 is a breaking cha ...
- express@4.0.*
$ sudo npm install -g express the installation goes fine. But when I try to create a project with ex ...
- 下篇:express、koa1、koa2的中间件原理
本作品采用知识共享署名 4.0 国际许可协议进行许可.转载联系作者并保留声明头部与原文链接https://luzeshu.com/blog/express-koa 本博客同步在http://www.c ...
- nodejs开发 express路由与中间件
路由 通常HTTP URL的格式是这样的: http://host[:port][path] http表示协议. host表示主机. port为端口,可选字段,不提供时默认为80. path指定请求资 ...
- [译]简单得不得了的教程-一步一步用 NODE.JS, EXPRESS, JADE, MONGODB 搭建一个网站
原文: http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/ 原文的源代码在此 太多的教程教你些一个Hello, World!了, ...
- express 框架之 路由与中间件
1. 什么是router路径,什么是middleware? 我们输入www.baidu.com 来访问百度的主页,浏览器会自动转换为 http://www.baidu.com:80/(省略一些参数) ...
- nodejs express 框架解密2-如何创建一个app
本文是基于express 3.4.6 的 1.在我们的app.js 文件里面有这么几行 http.createServer(app).listen(app.get('port'), function( ...
随机推荐
- Android app开发中用户协议(使用条款)文字自己主动换行
用户协议(使用条款)文字自己主动换行处理 转载请注明出处:http://blog.csdn.net/u012301841/article/details/46648821 我们在开发app的时候.常常 ...
- STM32定时器级联 -- AN2592
Master configuration When a timer is selected as a master timer, the corresponding trigger output si ...
- [Go] Cookie 使用简介
Golang 的 Cookie web 开发免不了要和 cookie 打交道.Go 的 http 库也提供了 cookie 的相关操作. type Cookie struct { Name strin ...
- Revit Family API 添加参数与尺寸标注
使用FamilyManager其他的与普通添加参数与标注没区别. [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Man ...
- Snmp学习总结(五)——WindowsServer2008安装和配置SNMP
一.安装SNMP 在Windows Server 2008以及Windows Server 2008 R2中,SNMP是以一个服务器功能的形式存在的,SNMP的安装步骤如下所示: 1.打开[开始]→[ ...
- 什么是.Net, IL, CLI, BCL, FCL, CTS, CLS, CLR, JIT
什么是.NET? 起源:比尔盖茨在2000年的Professional Developers Conference介绍了一个崭新的平台叫作Next Generation Windows Service ...
- 字符串转换成整型,到底使用int.Parse,Convert.ToInt32还是int.TryParse?
当我们想把一个字符串转换成整型int的时候,我们可能会想到如下三种方式:int.Parse,Convert.ToInt32和int.TryParse.到底使用哪种方式呢? 先来考虑string的可能性 ...
- 在ASP.NET MVC中使用Knockout实践08,使用foreach绑定集合
本篇体验使用 foreach 绑定一个Product集合. 首先使用构造创建一个View Model. var Product = function(data) { this.name = ko.ob ...
- Android 应用开发特色
Android 系统到底提供了哪些东西,供我们可以开发出优秀的应用程序.1. 四大组件Android 系统四大组件分别是活动(Activity).服务(Service).广播接收器(Broadcast ...
- Maven settings配置中的mirrorOf
原文地址:http://blog.csdn.net/isea533/article/details/21560089 使用maven时,从来没仔细注意过setting配置节点的作用,直到今天配置总是不 ...