I’ve created a react page using vite and it works and runs locally but when deployed to netlify I encounter this error on the console:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “application/octet-stream”. Strict MIME type checking is enforced for module scripts per HTML spec.
As you are building a Vite/React app, you need to provide a build command, and a publish directory otherwise Netlify will deploy the files in the repository as is. See
In this instance the build command to use is npm run build, and the publish directory is dist which is the vite default.
Pushing the node_modules directory is not required as Netlify (and likely most platforms) will install the required modules when building and cache them. There are also a couple of modules used that are not in the package.json. These will cause the build to fail until you add them.
Ahh @Veenakrishna thanks so much for sharing that. I’m glad you got unstuck. Please let us know if you have any other questions I also responded on your other post. (:
Hi Sam, I have the same issue. But this solutions didnt work for me. can you look into it?
this is the error:
main.jsx:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “application/octet-stream”. Strict MIME type checking is enforced for module scripts per HTML spec.
Hi, I am seeing that your site is not available. Please refer to this support guide and see if this helps first. If this is not working please share your build log and build settings.
Hey sam i am facing the same problem i have build this project with vite + react and I have run vite build https://669bc853217e10000808ba9a--movieenthusiast.netlify.app/
this is my website link but the
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “application/octet-stream”. Strict MIME type checking is enforced for module scripts per HTML spec.
error is consistent