0

I'm adding a JS file to Html yet I'm getting a syntax error "Uncaught SyntaxError: Unexpected identifier"

    <script src="./includes/vuetags/main.js" ></script>

JS file (main.js) - the error is traced by chrome to line 1

import VoerroTagsInput from './VoerroTagsInput.vue';

window.VoerroTagsInput = VoerroTagsInput;

export default VoerroTagsInput

Any ideas why it tells me I have an error?

Ended up finding that this action requires running Vuejs CLI (https://v2.vuejs.org/v2/guide/single-file-components.html)

1 Answer 1

1

I suspect that the error is not in line 1 of "main.js" (the file you show), but in line 1 of the included "VoerroTagsInput.vue". A "*.vue" file is a custom file format that uses HTML-like syntax to describe a Vue component. Thus, you cannot import JavaScript code from there.

Sign up to request clarification or add additional context in comments.

3 Comments

So how do I import the file shown here: github.com/voerro/vue-tagsinput/tree/master/src ?
@RoyGranit I have no idea, but it really does not look like it's JavaScript.
Working with .vue files requires a more advanced set of tools. Refer to vuejs.org/v2/guide/single-file-components.html to get the idea behind the concept.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.