koa2 使用nodemon 没任何反应 也不会重启
"scripts": {
"start": "node_modules/.bin/nodemon --harmony bin/www",
"pm2": "NODE_ENV=production pm2 --node-args='--harmony-async-await' start bin/www ",
"stylus": "stylus -u autoprefixer-stylus static/stylus -w -o static/css"
},
运行 npm run start 的时候 不会重启
bin/www
#!/usr/bin/env node
global.Promise = require('bluebird')
const app = require('../app')
app.js
/**
* 运行配置
*/
const Conf = require('./config')
const Koa = require('koa')
const app = new Koa()
const logger = require('koa-logger')
const error = require('koa-error')
const bodyParser = require('koa-bodyparser')
const Pug = require('koa-pug')
const serve = require('koa-static');
const convert = require('koa-convert')
/**
* pug
*/
const pug = new Pug({
viewPath: './views',
debug: false,
pretty: false,
compileDebug: false,
locals: '',
helperPath: [],
app: app
})
pug.locals = Object.assign(pug.locals, {
sitename: Conf.siteName
})
/**
* middleware
*/
app.use(logger())
app.use(bodyParser())
app.use(error({
engine: Conf.engine,
template: __dirname + '/views/error.pug'
}))
/**
* database
*/
const database = require('./config/database')
try {
database.connect()
} catch (error) {
console.log(error)
}
/**
* 静态文件夹
*/
app.use(convert(serve(__dirname + '/static')))
/**
* stylus
*/
/**
* 路由
*/
const api = require('./routes/api')
const web = require('./routes/web')
app.use(api.routes())
app.use(web.routes())
app.listen(Conf.port, () => {
console.log(`the serve is runing at port ${Conf.port}`)
})
module.exports = app
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遇到同样的问题