Vladyslav Zhadchenko
Vladyslav Zhadchenko

Reputation: 59

Cannot load the script with the type "module"

In the file script.js there are features of ES6 like import. For this, I connect script.js as a module, without the type = 'module' the browser generates an error. But when I connect the script

<script type = "module" src = "script.js"> </ script>

as a module, in the Chrome browser (v67), the console pops up an error:

Access to Script at 'file: /// D: /PROJECT/playing_field/src/script.js' from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access.

how to connect a script as a module?

Upvotes: 3

Views: 3751

Answers (1)

Amin NAIRI
Amin NAIRI

Reputation: 2504

You need to serve your page with a Web server. If you didn't have already one configured and are using Google Chrome, you can use the Web Server for Chrome.

Upvotes: 3

Related Questions