my-egg-application
$ mkdir my-egg-application
不熟悉命令行的同窗也能够手动建立文件夹node
$ cd my-egg-application
$ npm init egg --type=simple
这里的type
参数是须要下载的模板名字,具体的值能够参考egg在github上的模板egg-boilerplate-simple
。在egg的项目主页中找相似格式的项目名字,如egg-boilerplate-[命令行中type的值]git
$ npm install --registry=https://registry.npm.taobao.org
在这里下载比较慢的同窗能够使用淘宝的cnpm,具体的cnpm安装方法请本身网上搜索,不少相似的教程。我为了方便直接就指定了淘宝仓库地址 https://registry.npm.taobao.org
github
运行项目就比较简单了,运行npm的命令shell
$ npm run dev
在浏览器中打开地址:http://localhost:7001,就能看到服务已经启动完成。是否是特别简单!!!npm
npm run [命令]
这是npm相关的使用方法,能够打开项目根目录下的package.json文件json
// 这是一个最简单的package.json { "name": "my-egg-application", "version": "1.0.0", "description": "", "scripts": { "dev": "egg-bin dev", }, "author": "mufeng", "license": "ISC" }
在script下面看到了dev命令,它其实运行了egg-bin dev
这个命令,egg-bin
这个模块之后我会再写一篇文章介绍一下segmentfault