The import directive loads the module by path ./sayHi.js relative to the current file, and assigns exported function sayHi to the corresponding variable.. Let’s run the example in-browser. Node does not yet support the ES6 module format and you will get errors like: SyntaxError: Cannot use import statement outside a module SyntaxError: Unexpected identifier // need @babel/preset-env to use import SyntaxError: Cannot use import statement outside a module. As modules support special keywords and features, we must tell the browser that a script should be treated as a module, by using the attribute