google / marzipano

A 360° media viewer for the modern web.
http://www.marzipano.net
Apache License 2.0
1.95k stars 992 forks source link

Cannot use import nor require in demos #438

Open Sherry1016 opened 1 year ago

Sherry1016 commented 1 year ago

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 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.

Could you guys please help me with that?