LifeAsDev
LifeAsDev

Reputation: 1

How host on github pages?

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

Answers (1)

traktor
traktor

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

Related Questions