Reputation: 1
I host my vitejs project on github pages, and I'm getting this in the command console
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/jsx". Strict MIME type checking is enforced for module scripts per HTML spec.
my project https://github.com/LifeAsDev/intro
should display correctly
Upvotes: 0
Views: 103
Reputation: 19376
.jsx
files are not javascript
"jsx" stands for "JavaScript XML" and can be included directly in HTML using a script tag attribute of type="jsx"
instead of type="module"
. But browsers won't compile such files automatically - the page would also need to include script tags in index.html
to load react standalone dev mode files from a CDN. The standalone react files would then compile .jsx
files into JavaScript using babel each time the page is loaded. This may be suitable for demonstration purposes since (presumably) the file will not be used for production.
Another alternative would be to build a react app from your project which, in the process, would compile jsx
files into JavaScript using babel. A tutorial for this that uses create-react-app
is available on GitHub at Deploying a React App to GitHub Pages
Upvotes: 0