0

I wanted to check out vue and use it for my next project. I wanted to use Hooper, a image carousel. I've installed it via npm install hooper. Now in my script file I use

  import { Hooper, Slide } from 'hooper';
  import 'hooper/dist/hooper.css';

  export default {
    name: 'App',
    components: {
      Hooper,
      Slide
    }
  }

But that already throws an error in the first line:

Uncaught SyntaxError: Unexpected token {

I've already installed it in one folder above the script file, besides it, and in a folder, but the js file does not recognize the bracket. How do I solve this?

Mobeen Sarwar
  • 514
  • 5
  • 23
  • 1
    Do you use webpack? Or just trying to run this code via browser? https://stackoverflow.com/questions/41722621/es6-in-the-browser-uncaught-syntaxerror-unexpected-token-import – Emīls Gulbis Sep 19 '19 at 06:16
  • _"Now in my script file..."_ which script file is that? – Phil Sep 19 '19 at 06:17
  • No, I don't use webpack, because I use Kirby as CMS, and there is no documentation in using a copiler with a CMS. Of course I want to use it in my browser, where else lol –  Sep 19 '19 at 06:21
  • Correct me if I get any of this wrong but I'm guessing this is in a `.js` file and you are running `node path/to/script.js` and seeing the error in your terminal / cli. If so, check out [How can I use an es6 import in node?](https://stackoverflow.com/questions/45854169/how-can-i-use-an-es6-import-in-node) – Phil Sep 19 '19 at 06:26
  • I've also tried to use this script inside my html file, between script tags, but still got this error. –  Sep 19 '19 at 06:30
  • Are you reading any of the links we're giving you? – Phil Sep 19 '19 at 06:30
  • Like this: –  Sep 19 '19 at 06:32
  • So is it right to assume that you are including vuejs as a script in your html header? Something like `` – skribe Sep 19 '19 at 06:48

1 Answers1

0

Ok; I did not know that I have to wrap the script inside <script type="module"></script> Apparently it works now. Thanks?