HTML How to use script type module? [duplicate]

When I use module and type the following:

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

I get this error in the console:

Access to script at ‘file:///file path here’ from origin ‘null’ has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.

However, if I remove type="module" there will be no error.
I want to use module – how can I do this?