ERROR: Failed to parse file [___.vue] at line 459: 'import' and 'export' may appear only with 'sourceType: module'

SonarQube version:

Enterprise Edition Version 8.4.2 (build 36762)

Scanner Info:

INFO: SonarScanner 4.4.0.2170
INFO: Java 11.0.6 AdoptOpenJDK (64-bit)
INFO: Linux 3.10.0-1062.4.1.el7.x86_64 amd64

Error observed:

ERROR: Failed to parse file [___.vue] at line 459: 'import' and 'export' may appear only with 'sourceType: module'

Minimum source code required to reproduce this error:

<template>
  <div />
</template>

<script>
export default {
  name: 'TestComponent',
  data: () => ({
    userInfo: {
      information: {
        userType: 'B',
      },
    },
  }),
  computed: {
    userCustomerType() {
      return this.userInfo?.information?.userType || 'C'
    },
  },
}
</script>

Notes:

  • When I remove the optional chaining from the userCustomerType computed property, the error goes away.
  • Without the error I get a successful scan:
    =
  • With the error I get a successful scan, but the file is skipped:

c.c. @Lena and @Yassin_Kammoun

Hello @Brett_Oberg ,

we tested and it seems this issue is fixed in the latest version of SonarQube. Can you please try with LTS 8.9 version?

@saberduck thanks for getting back to me!

Okay, that sounds good! I will run the update and try again, thanks.

@saberduck The upgrade solved the issue! Thanks for the help.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.