1

So I'm getting the following error when I try to load an external js file in the index.html

Uncaught SyntaxError: Unexpected token <

This how I'm calling it:

<script async src="/src/assets/fabric.min.js"></script>

I'm not sure why it's giving this error because if I use cdnjs it works fine:

<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.7.22/fabric.min.js"></script>

I can provide more details if necessary.

12
  • 3
    It looks like the path is wrong and your server is serving HTML instead (like a 404 error page). Commented Jan 9, 2018 at 23:59
  • What does it say in your browser's address bar? Commented Jan 10, 2018 at 0:03
  • Try to use this this link https://www.npmjs.com/package/fabric then install it using Vue.use(fabric) Commented Jan 10, 2018 at 0:04
  • @ChrisG If you're asking about the url, I'm running on localhost: http://localhost:8080/#/ Commented Jan 10, 2018 at 0:04
  • 1
    @A.Lau Exactly, the server sends back the index file, which starts with <. But you already solved it. Commented Jan 10, 2018 at 0:22

1 Answer 1

2

Solved this by moving the required file into the static folder.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.