Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
34
rated 0 times [  37] [ 3]  / answers: 1 / hits: 116822  / 7 Years ago, wed, january 18, 2017, 12:00:00

I'm new to ES6 (ECMAScript 6), and I'd like to use its module system in the browser. I read ES6 is supported by Firefox and Chrome, but I'm getting the following error using export



Uncaught SyntaxError: Unexpected token import



I have a test.html file



<html>
<script src=test.js></script>
<body>
</body>
</html>


and a test.js file



'use strict';

class Test {

static hello() {
console.log(hello world);
}
}

export Test;


Why?


More From » html

 Answers
7

Many modern browsers now support ES6 modules. As long as you import your scripts (including the entrypoint to your application) using <script type=module src=...> it will work.



Take a look at caniuse.com for more details:
https://caniuse.com/#feat=es6-module


[#59304] Tuesday, January 17, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raymondd

Total Points: 620
Total Questions: 112
Total Answers: 94

Location: Namibia
Member since Mon, Feb 21, 2022
2 Years ago
;