ESLint: Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
See original GitHub issueCreated new simple project with one file:
import React from 'react';
import { render } from 'react-dom';
import { Router, browserHistory } from 'react-router';
render((
<Router history={browserHistory} routes={routes}>
</Router>
), document.getElementById('root'));
created simple .eslintrc with the help eslint --init:
{
"env": {
"es6": true,
"node": true,
"browser": true
},
"extends": "eslint:recommended",
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
},
"plugins": [
"react"
],
"rules": {
"no-console": 0,
"indent": [
2,
4
],
"quotes": [
2,
"single"
],
"semi": [
2,
"always"
]
}
}
enabled esLint settings in IDEA and got the error:
Error:(1, 1) ESLint: Parsing error: ‘import’ and ‘export’ may appear only with ‘sourceType: module’
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
'import' and 'export' may appear only with 'sourceType: module ...
I get this error since the most recent update. is it possible there this is missing somewhere in the package?
Read more >ignore eslint error: 'import' and 'export' may only appear at the ...
my solution incase other dont work "parserOptions": { "ecmaVersion": 6, "sourceType" ...
Read more >'import' and 'export' may appear only with 'sourceType: module ...
We use https://www.npmjs.com/package/vue-eslint-parser to parse vue files. We first try with sourceType: 'module' and then with sourceType: ' ...
Read more >ESLint - HackingNote
Ignore Warning: Parsing error: 'import' and 'export' may only appear at the top level. Use babel-eslint as parser and allow import/export ...
Read more >eslint/eslint - Gitter
ESLintError in plugin 'gulp-eslint' Message: Parsing error: 'import' and 'export' may appear only with 'sourceType: module'.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You need to add
sourceType: "module"
to your config. There is no way for us to identify automatically what’s a script and what’s a module, so you have to provide that information in config file. For more details look in the documentationthanks