我在我的项目中使用了 create-react-app。我收到错误
Uncaught SyntaxError: Unexpected token export
错误在这段代码中
export const ENGLISH = {
lang: 'en',
messages: {
'nav.translatedMessage': 'Social',
}
};
我尝试安装 babel-preset-es2015 和 babel-preset-stage-0。我还把 babel dict/object 包含在 package.json 中作为
"babel": {
"presets": [
"es2015",
"stage-0"
]
},
我仍然遇到错误。
最佳答案
我在 create-react-app 的 README.md 上得到了答案。上面写着
You may create subdirectories inside
src
. For faster rebuilds, only files insidesrc
are processed by Webpack.
You need to put any JS and CSS files insidesrc
, or Webpack won’t see them.
关于javascript - 未捕获的语法错误 : Unexpected token export,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40756359/