ESLint: Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

See original GitHub issue

Created 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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
ilyavolodincommented, Mar 11, 2016

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 documentation

0reactions
budarincommented, Mar 11, 2016

thanks

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found