I am encountering an issue when deploying a project built with React.js (v18.2.0). I’ve been struggling with this for months and have yet to find a solution.
After writing code in my local environment and pushing it, the CI/CD pipeline builds the project using Docker and yarn build. The build process completes successfully.
However, if a page is already open in the browser, navigating through the React.js project’s pages sometimes causes the browser to go blank, displaying the following error:
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.
This issue does not seem to be specific to any particular path and was not present when running the project using Vite.
If you have encountered a similar issue or can suggest appropriate search keywords, your help would be greatly appreciated. Thank you for your time.
Including file extensions in import statements (e.g., import ‘~/Sample/index.js’)
Adding build: { manifest: true } to vite.config.js
Googling for solutions (e.g., “White screen after deployment react”, “react + error code”, etc.)
However, if a page is already open in the browser, navigating through the React.js project’s pages still sometimes causes the browser to go blank.
modify:
In the browser’s developer tools, checking the network tab shows that a normal response (200) was received.
Nshell is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.