However, when I use import in the data.js, it told me to add the "type": "module" in the package, I added it but it does not work
then I tried another way. I added <script type="module" src="data.js"></script> to the index.html, and then I can import the fetch package, but the console told me that:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
Hi guys, I wanted to add a demo inside the directory demos, and I wanted to import/require a fetch package in my data.js
Structure: -package.json -demos-myNewDemo-index.js -demos-myNewDemo-data.js -demos-myNewDemo-index.html
However, when I use import in the data.js, it told me to add the
"type": "module"
in the package, I added it but it does not workthen I tried another way. I added
<script type="module" src="data.js"></script>
to the index.html, and then I can import the fetch package, but the console told me that:Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
Could you guys please help me with that?