# ES6语法支持

使用es6语法后, 不能直接使用 node src/index运行项目

// const Koa = require('koa')
import Koa from 'koa'    // ⭐⭐⭐
const path = require('path')
const app = new Koa()
const helmet = require('koa-helmet')
const statics = require('koa-static')

const router = require('./routes/routes')
app.use(helmet())
app.use(statics(path.join(__dirname, '../public')))
app.use(router())

app.listen(3000)
1
2
3
4
5
6
7
8
9
10
11
12
13
xcooo

需要使用以下命令运行

npx babel-node src/index
1

使用 nodemon去运行

npx nodemon --exec  babel-node  src/index
1
上次更新: 2020/12/4 下午3:37:40