Access to Script at ' from origin 'null' has been blocked by CORS policy
ES6 modules are subject to same-origin policy. You need to run your script from a local server, opening the file directly with a browser will not work.
see here ES6 module support in Chrome 62/Chrome Canary 64, does not work locally, CORS error
Looks like you're trying to open the web-page locally (via file://
protocol) i.e. double clicking the .html
file. Unfortunately modules only work via HTTP(s), so all you need to do is use a local web server. Popular choices include:
Live Server, a VS Code extension that adds a right-click option to run your pages with a local server.
Node static server, a simple http server to serve static resource files from a local directory.
Node live server is easy to install and use:
npm install -g live-server // Install globally via npm live-server // Run in the html's directory