Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token export #65

Closed
Luncher opened this issue Feb 14, 2017 · 5 comments
Closed

SyntaxError: Unexpected token export #65

Luncher opened this issue Feb 14, 2017 · 5 comments

Comments

@Luncher
Copy link

Luncher commented Feb 14, 2017

configure:

plugins: [
["babel-plugin-root-import", {
"rootPathPrefix": "~",
"rootPathSuffix": "../src"
}]
]

code:

base.js

'use strict';

import Base from '~/common/controller/';

export default class extends Base {
  // async getAction() {
  //   let ret;

  //   ret = await super.getAction();
  //   this.success(ret);
  // }
}

controller/index.js

'use strict';


/**
 *  Base Restful controller
 */

export default class extends think.controller.rest {

error message:

[2017-02-14 11:11:28] [Error] /Users/luncher/work/admin-plus/src/common/controller/index.js:8
export default class extends think.controller.rest {
^^^^^^
SyntaxError: Unexpected token export
@Luncher
Copy link
Author

Luncher commented Feb 14, 2017

This is because this plugin does not support es6?

@michaelzoidl
Copy link
Member

Seem's like you've not installed the babel-preset-es2015, since the import feature is not implemented in the default babel-preset (it's not a confirmed standard yet)

Install / add this package and try again :)

@Luncher
Copy link
Author

Luncher commented Feb 16, 2017

I have already loaded the plugin, but it is still suggesting that this error.

@Guatom
Copy link

Guatom commented Jul 28, 2017

Just as a workaround, you could try to change export default to module.exports =.

@AnthonyNahas
Copy link

i have recently resolved a similar issue. Please take a look of my solution here

@brigand brigand closed this as completed May 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants