Parsing error: Unexpected token `import`
See original GitHub issue- ESLint Version: 5.10.0
- Node Version: 11.4.0
- npm Version: 6.4.1
What parser (default, Babel-ESLint, etc.) are you using?
Default.
Please show your full configuration:
Configuration
{
"extends": "eslint",
"parserOptions":{
"ecmaVersion": "2018",
"sourceType": "module"
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
// Workaround for `--experimental-modules`
// See <https://nodejs.org/docs/latest/api/esm.html#esm_import_meta>
const __dirname = Path.dirname(new URL(import.meta.url).pathname)
eslint sample.mjs
What did you expect to happen?
A decent report.
What actually happened? Please include the actual, raw output from ESLint.
3:40 error Parsing error: Unexpected token import
✖ 1 problem (1 error, 0 warnings)
Are you willing to submit a pull request to fix this bug?
No.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Dynamic Imports for Code Splitting cause: ESLint Parsing ...
My code runs and works as expected when using npm run dev and npm run build , but this parsing error prevents the...
Read more >ESLint Parsing error: Unexpected token - rockyourcode
ESLint Parsing error: Unexpected token. ESLint throws some errors: error Parsing error: The keyword 'import' is reserved or, when using JSX: ...
Read more >eslint/eslint - Gitter
I'm using sourceType module.. but still getting error Parsing error: Unexpected token import. Kevin Partington. @platinumazure.
Read more >[ESLint] Parsing error: unexpected token - DEV Community
This is a solution when I saw these errors. ... Warning: React version not specified in eslint-plugin-react settings. See https://github.com/ ...
Read more >import.meta.url - Parsing error: Unexpected token import
You received this message because you are subscribed to the Google Groups "ESLint" group. To unsubscribe from this group and stop receiving ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
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
Now with this config:
and installing
babel-eslint
, the error was gone. Thanks for the solution!Though I personally can’t consider this ticket is resolved. But I’ll leave the decision to you guys.
@seamlik That’s right. Currently, the solution is to use the babel-eslint parser. That being said, there are plans to change babel-eslint to expect babel as a peer dependency. The assumption is that anyone using babel-eslint is also using babel, but you’ve hit a case where that isn’t true.