javascriptvue.jssvelte

SyntaxError: ambiguous indirect export: default Error when importing my own class


I have written a validation class and want to include it in my VueJS 3 project. Unfortunately I get the following error: SyntaxError: ambiguous indirect export: default

This is my code:

// ..classes/formValidationClass.js
export class FormValidator {
...
}

// some vue file with a form
import FormValidation from "..classes/formValidationClass"

export default {...}

What does this error mean and what do I have to do to correct the error?


Solution

  • Use braces {} around your import Name

    // ..classes/formValidatorClass.js // Comment: => suggestion change your file name to similar your class name
    export class FormValidator {
    ...
    }
    
    // some vue file with a form
    // import FormValidation from "..classes/formValidationClass"
    import { FormValidator as FormValidation} from "../classes/formValidatorClass"; // Comment: => use brackets around your import name. if you want use FormValidation you can use also a alias (`originalName as newName`)
    
    export default {...}