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