[英]create-react-app eslint error "Parsing error: 'import' and 'export' may appear only with 'sourceType: module'"
I have just created a new app using create-react app and eslint is giving me this error Parsing error: 'import' and 'export' may appear only with 'sourceType: module'我刚刚使用 create-react app 创建了一个新应用程序,eslint 给了我这个错误解析错误:'import' 和 'export' 可能只出现在 'sourceType: module'
i am new to react and dont know what i am doing wrong, though the app is running fine I am using VS code editor.我是新手,不知道我做错了什么,虽然应用程序运行良好,但我使用的是 VS 代码编辑器。 How to remove this problem?
如何消除这个问题?
Try adding sourceType: "module"
To the eslint configuration尝试将
sourceType: "module"
添加到 eslint 配置中
// in .eslintrc.js (recommended) or .eslintrc (deprecated)
{
...
"parserOptions": {
...
"sourceType": "module"
...
}
...
}
https://eslint.org/docs/user-guide/configuring#specifying-parser-options https://eslint.org/docs/user-guide/configuring#specifying-parser-options
Since I am unable to upvote yet, @Yossi is right, add the proper sourceType into your eslintrc.js/.json file.由于我还无法投票,@Yossi 是对的,将正确的 sourceType 添加到您的 eslintrc.js/.json 文件中。 Worked for me.
为我工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.