Explain please can not understand what I'm doing wrong. There is such code:
Exporting an anonymous function by default. File flash-message.js :
export default function(message){ console.log(message); } Next, I import this thing into the app.js file:
import flashMessage from './flash-message'; flashMessage("hello!"); And I connect both modules to index.html :
<!doctype html> <html> <body> <script src="./flash-message.js"></script> <script src="./app.js"></script> </body> </html> In the manual for which I do, everything works. My chrome writes an error:
flash-message.js: 1 Uncaught SyntaxError: Unexpected token export
app.js: 1 Uncaught SyntaxError: Unexpected token import
There are two points that are not clear to me:
Why in the tutorial, on video, such a structure works. And chrome does not produce errors.
Why if I translate this code using babel ("presets": ["es2015"]). In the node interpreter, the code works, but in chrome it’s still an error.