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流量统计
研究过一段时间的android流量统计发个自己的总结帖 1 android有一个TrafficStats类可以直接获取 总接受流量TrafficStats.getTotalRxBytes(), 总发送 ...
- MongoDB中的变更通知
MongoDb 3.6中引入了一个新特性change stream,简单的来说就是变更通知,它提供了一个接口允许应用实时获取数据库变更,这个在ETL.数据同步.数据迁移.消息通知等方面非常有用. 使用 ...
- BrowserLog——使用Chrome控制台作为Log查看器
Chrome控制台是十分强大的,即使将它作为一个log查看器也是非常强大的,BrowserLog就是一个.net下的把Chrome作为log输出的程序包. 原理非常简单,server端将log数据通过 ...
- 反接保护电路 Reverse Voltage Protection
Reverse Voltage Protection I've long wanted to pull together some reverse polarity protection ideas ...
- [Node.js]连接mongodb
摘要 前面介绍了node.js操作mysql以及redis的内容,这里继续学习操作mongodb的内容. 安装驱动 安装命令 cnpm install mongodb 安装成功 数据库操作 因为mon ...
- Android framework回想(2) sp 和 wp sp对象
用MediaPlayer说明sp的实现.sp是一个模板类,T是RefBase的子类.仅仅要继承于RefBase的类都能够使用sp. binder类也继承RefBase类,binder的实现离不开Ref ...
- 在ASP.NET MVC中使用Knockout实践02,组合View Model成员、Select绑定、通过构造器创建View Model,扩展View Model方法
本篇体验使用ko.computed(fn)计算.组合View Model成员.Select元素的绑定.使用构造器创建View Model.通过View Model的原型(Prototype)为View ...
- ASIHTTPRequestErrorDomain Code=5
ASIHttpRequest解析带空格的URL时 出错!!!(已解决) 用的是post请求 URL 地址是: http://111.234.51.56/login_member.pl?time=201 ...
- WordPress基础:wp_list_pages显示页面信息列表
函数:wp_list_pages($args) 作用:列出某个分类下的分类项目 常见参数说明: 参数 用途 值 sort_column 排序方式 post_title 按标题排序 [默认] m ...
- 纸牌屋第一季/全集House of Cards迅雷下载
纸牌屋 第一季 House of Cards Season 1 (2013) 本季看点:经过数轮激烈角逐,新一届美国总统加勒特·沃克(迈克·吉尔 Michael Gill 饰)诞生,自称水管工的众议院 ...