In the browser where I use the script with import export operators displays an error

Uncaught SyntaxError: Unexpected identifier

I study Ecmascript 6 but I cannot understand and find how import and export work, what technology do they use and how does everything work?

Information and literature on this topic is very small.

If there are links I will be glad to see.

2 answers 2

import and export are not supported in all browsers, in some you need to add additional permissions in the settings.

For example:

  1. EDGE - about:flags select the checkbox edge enable experiment
  2. Chrome - version 61 enabled by default

In order to be able to use import , export , you need to set the corresponding script tags: type="module"

  • Do I need to use webpack, babel ... if the browser supports Import export? - a_mine
  • @a_mine, at your discretion, webpack and babel, in addition to import / export, do a lot of additional things. Plus, the modules are not yet supported everywhere, and it cannot be guaranteed that the code will work with them everywhere without additional actions on the part of the user. - Grundy
  • If I set type = "module" in chrome, is it possible to do without webpack (i.e., does the browser understand the model or do I need to make a bundle)? - a_mine
  • @a_mine, the answer also states that in chrome, starting from version 61, support is enabled by default - Grundy

Brazer does not support modules. import / export will not work in the browser. This is done for security purposes. to achieve modularity, you can use a package builder like Webpack . It will merge your js files into one. But it is worth warning that the builds work on node js which does not support es6 import / export. use babel to convert your code!

  • Use the Russian keyboard. Or translit . - 0xdb
  • In fact, they already support, maybe not all browsers - Grundy