简体   繁体   中英

Uncaught SyntaxError: Unexpected token export

I have used create-react-app for my project. I am getting an error of

Uncaught SyntaxError: Unexpected token export

The error is in this code

export const ENGLISH = {
  lang: 'en',
  messages: {
      'nav.translatedMessage': 'Social',
  }
};

I tried installing babel-preset-es2015 and babel-preset-stage-0. Also i included the babel dict/object in package.json as

"babel": {
    "presets": [
      "es2015",
      "stage-0"
    ]
  },

I am still getting an error.

在此处输入图片说明

I got my answer on README.md of create-react-app. There it says

You may create subdirectories inside src . For faster rebuilds, only files inside src are processed by Webpack.
You need to put any JS and CSS files inside src , or Webpack won't see them.

I think its because of the comma

export const ENGLISH = {
       lang: 'en',
       messages: {
           'nav.translatedMessage': 'Social'
       }
};

Try doing this !

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