简体   繁体   中英

Babel Unexpected token export

I just wanted start a new project using babel and ES2016 so i can use await async in new project. In babelrc i put following:

{
    "presets": [
        "es2016",
        "stage-0"
    ]
}

And than in index.js i have:

require('babel-core/register')()
require('babel-polyfill')
require('./bin/server.js')

But now in server.js it fails when i run the app, at first line because of import:

import Koa from 'koa'

Saying that it does not recognize "import". The packages i installed are babe-cli, core, polyfill,preset-es2016, preset-stage-0 and babel-register. Am i missing something or what am i doing wrong?

我认为您需要安装npm install --save-dev babel-preset-es2015

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM