Parsing error: 'import' and 'export' may only appear at the top level
See original GitHub issueTell us about your environment
- ESLint Version: 5.4.0
- eslint-plugin-vue Version: 5.0.0-beta.3
- Node Version: 10.8
Please show your full configuration:
module.exports = {
root: true,
extends: [
'plugin:vue/recommended',
'dwing'
],
parserOptions: {
sourceType: 'module',
allowImportExportEverywhere: true
}
};
What did you do? Please include the actual source code causing the issue.
export default {
name: 'Aplayer',
mounted() {
const that = this;
// error
import('aplayer').then(({ default: Aplayer }) => {
});
}
};
What did you expect to happen?
dynamic import for performance
What actually happened? Please include the actual, raw output from ESLint.
{
"resource": "/Users/willin/Documents/websites/blog/src/.vuepress/theme/components/sidebar/player.vue",
"owner": "eslint",
"code": "undefined",
"severity": 8,
"message": "Parsing error: 'import' and 'export' may only appear at the top level",
"source": "eslint",
"startLineNumber": 12,
"startColumn": 4,
"endLineNumber": 12,
"endColumn": 4
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
'import' and 'export' may only appear at the top level
I'm using webpack with vuejs. Webpack does its thing, but when I look at the outputted app.js file, it gives me this error....
Read more >'import' and 'export' may only appear at the top level | bobbyhadz
The error "import and export may only appear at the top level" occurs when we forget a closing brace when declaring a function...
Read more >How to fix: import and export may only appear at the top level
So I've setup a new Svelte project and install all the latest node modules. ... If you're developing a Svelte project, you're probably...
Read more >'export' may only appear at the top level | Velo by Wix
Hey, I'm getting an error "Modifiers cannot appear here. Parsing error: 'import' and 'export' may only appear at the top level" Here's the ......
Read more >ESLint - HackingNote
ESLint · Ignore Warning: Parsing error: 'import' and 'export' may only appear at the top level · Ignore Warning: react/prop-types.
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

parsershould go beforeparserOptions, not inside it.Dynamic import may not be supported by eslint default parser. It seems to solve by using
babel-eslint.https://github.com/eslint/eslint/issues/9927
Could you try it?