Error: "Uncaught SyntaxError: Unexpected token import" in javascript

0

Good afternoon, I have the following program:

testing.html:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title> Testando </title>
  </head>
  <body> 

    <p> oi </p>

    <script language="JavaScript" src="arquivo.js"></script>


  </body>
</html>

and the .js file:

  import { createStore } from 'redux';

  function oi(a)
  {
    console.log(a)
  }

  console.log("oi")
  let a=4
  oi(a)

I'm trying to learn how to use redux, but when using import, the browser returns me the error: Uncaught SyntaxError: Unexpected token import. I would like to know why this error occurred

    
asked by anonymous 04.04.2018 / 19:40

1 answer

0

You are using JavaScript modules. You must enter the type="module" attribute in the <script> tag:

<script type="module" language="JavaScript" src="arquivo.js"></script>

There is a question that deals with the subject this link .

    
04.04.2018 / 20:36