koa
- 全局安装koa生成器
npm install koa-generator -g
- 创建项目
koa2 service
- 安装依赖
cd service
npm install
- 执行服务
npm run start
- 监听文件改动自动重启
npm install supervisor --save-dev
修改package.json, 使用supervisor代替node
{
"name": "service",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "supervisor bin/www",
"dev": "./node_modules/.bin/nodemon bin/www",
"prd": "pm2 start bin/www",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"debug": "^4.1.1",
"koa": "^2.7.0",
"koa-bodyparser": "^4.2.1",
"koa-convert": "^1.2.0",
"koa-json": "^2.0.2",
"koa-logger": "^3.2.0",
"koa-onerror": "^4.1.0",
"koa-router": "^7.4.0",
"koa-static": "^5.0.0",
"koa-views": "^6.2.0",
"pug": "^2.0.3"
},
"devDependencies": {
"nodemon": "^1.19.1",
"supervisor": "^0.12.0"
}
}