question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error Parsing error: Unexpected token import

See original GitHub issue

Tell us about your environment

  • ESLint Version: 4.8.0
  • eslint-plugin-vue Version: 3.13.0
  • Node Version: 7.5.0

Please show your full configuration:

module.exports = {
  root: true,
  parserOptions: {
    sourceType: 'module',
    ecmaVersion: 8,
  },
  extends: [
    'standard',
    'plugin:vue/recommended' // or 'plugin:vue/base'
  ],
  "env": {
    "browser": true,
  },
  // add your custom rules here
  'rules': {
    "indent": ["error", 2],
    "semi": ["error", "always"],
    "space-before-function-paren": ["error", "never"],
    // allow paren-less arrow functions
    'arrow-parens': 0,
    // allow async-await
    'generator-star-spacing': 0,
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
    // trailing comma
    'comma-dangle': ['error', 'always-multiline'],
  }
}

What did you do? Please include the actual source code causing the issue.

<template>
  <div id="app">
  </div>
</template>

<script>
export default {
  name: 'app2',
  components: {
    'component1': () => import('./components/Component1.vue'),
  },
  data() {
    return {
      isShowComponent: false,
    };
  },
  methods: {
    showComponent: function(event) {
      this.isShowComponent = true;
    },
  },
};
</script>

<style scoped lang="scss">
</style>

What did you expect to happen?

What actually happened? Please include the actual, raw output from ESLint. src/App.vue 16:25 error Parsing error: Unexpected token import

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

49reactions
iztsvcommented, Oct 8, 2017

Sorry for the issue. I missed "parser": "babel-eslint" option in my .eslintrc.js config. Please, close the issue.

45reactions
armano2commented, Dec 11, 2018

https://vuejs.github.io/eslint-plugin-vue/user-guide/#what-is-the-use-the-latest-vue-eslint-parser-error

- "parser": "babel-eslint",
  "parserOptions": {
+     "parser": "babel-eslint",
      "ecmaVersion": 2017,
      "sourceType": "module"
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Parsing error: Unexpected token `import` · Issue #11189
I'm not sure I understand the problem. When using the default parser and sourceType: "module" , the word import becomes a keyword token...
Read more >
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 throws some errors: error Parsing error: The keyword 'import' is reserved or, when using JSX: error Parsing error: Unexpected token ...
Read more >
eslint/eslint - Gitter
I am having an issue with ESLint while deploying my react app to Heroku. I am getting this error "Oops! Something went wrong!...
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 >

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