admin管理员组文章数量:1291217
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 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.
Share Improve this question edited Nov 23, 2016 at 6:30 Serenity asked Nov 23, 2016 at 4:57 SerenitySerenity 4,0548 gold badges49 silver badges97 bronze badges 8-
Remove the
,
after'nav.translatedMessage': 'Social'
– Monasha Commented Nov 23, 2016 at 5:03 - @Monasha Already tried that. It did not work. This exact code worked when i did not use create-react-app. – Serenity Commented Nov 23, 2016 at 5:05
- Could you post the full error message? – loganfsmyth Commented Nov 23, 2016 at 6:26
- @loganfsmyth in a screenshot you see an error is in es.js but it is same with en.js too( the code i have posted above). – Serenity Commented Nov 23, 2016 at 6:31
- So if you look at the line throwing the error, what module is it? Is it your own code? Is it a node module? – loganfsmyth Commented Nov 23, 2016 at 6:35
2 Answers
Reset to default 6I got my answer on README.md of create-react-app. There it says
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.
I think its because of the ma
export const ENGLISH = {
lang: 'en',
messages: {
'nav.translatedMessage': 'Social'
}
};
Try doing this !
本文标签: javascriptUncaught SyntaxError Unexpected token exportStack Overflow
版权声明:本文标题:javascript - Uncaught SyntaxError: Unexpected token export - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741501681a2382085.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论