I am trying to understand modules in javascript but when I try to write a very simple module I get CORS error.I am using bracket as my text editor and the odd part is when Im using live preview in brackets the code works but when I normally open the .js file I get error.
index.html
<!DOCTYPE html>
<html>
<head>
<title> JS </title>
</head>
<body>
<script type="module">
import {add} from './libA.js';
console.log(add(10,20));
</script>
</body>
</html>
libA.js
export function add(a,b) {
return a+b ;
}
*I get this error -> Access to Script at 'file:///F:/WEB%20DEV/JavaScript/libA.js' from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access. (I try the latest version of chrome too)