Error while deploying vite project on github pages

  Kiến thức lập trình

The error is: 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 package.json part looks like following: {
“homepage”: “”,
“name”: “react-portfolio”,
“private”: true,
“version”: “0.0.0”,
“type”: “module”,
“scripts”: {
“predeploy”: “npm run build”,
“deploy”: “gh-pages -d dist”,
“dev”: “vite”,
“build”: “vite build”,
“lint”: “eslint . –ext js,jsx –report-unused-disable-directives –max-warnings 0”,
“preview”: “vite preview”
“dependencies”: {
“react”: “^18.2.0”,
“react-dom”: “^18.2.0”
“devDependencies”: {
“@types/react”: “^18.2.66”,
“@types/react-dom”: “^18.2.22”,
“@vitejs/plugin-react”: “^4.2.1”,
“eslint”: “^8.57.0”,
“eslint-plugin-react”: “^7.34.1”,
“eslint-plugin-react-hooks”: “^4.6.0”,
“eslint-plugin-react-refresh”: “^0.4.6”,
“gh-pages”: “^6.1.1”,
“vite”: “^5.2.0”

and following is my vite.config.js: import { defineConfig } from “vite”;
import react from “@vitejs/plugin-react”;

export default defineConfig({
base: “/react-portfolio/”,
plugins: [react()],

i have trying running npm run build which is also added in my deployment actions

New contributor

Aman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.