Sh: line 1: vite: command not found

hey so i am using vercel to deploy my react project with vite as the framework and it worked at first when running the build from visual studio code and connecting it to vercel using the vercel CLI then to just test that i can update the project through using git like committing and pushing
changes to the repository that it updates the deployed project on vercel , i made a heading change then commited and pushed it but now i get a failed deploy and the errors saying ; sh: line 1: vite: command not found Error: Command “vite build” exited with 127 , yet vite is included as a devdependency in my package.json,

Below is my package.json ;


{
  "name": "game-hub",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc -b && vite build",
    "lint": "eslint .",
    "preview": "vite preview"
  },
  "dependencies": {
    "@chakra-ui/react": "^3.2.3",
    "@chakra-ui/theme": "^3.4.6",
    "@chakra-ui/theme-tools": "^2.2.6",
    "@emotion/react": "^11.14.0",
    "@emotion/styled": "^11.14.0",
    "axios": "^1.7.9",
    "framer-motion": "^11.15.0",
    "next-themes": "^0.4.4",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-icons": "^4.12.0"
  },
  "devDependencies": {
    "@eslint/js": "^9.17.0",
    "@types/node": "^22.10.2",
    "@types/react": "^18.3.18",
    "@types/react-dom": "^18.3.5",
    "@vitejs/plugin-react": "^4.3.4",
    "eslint": "^9.17.0",
    "eslint-plugin-react-hooks": "^5.0.0",
    "eslint-plugin-react-refresh": "^0.4.16",
    "globals": "^15.14.0",
    "typescript": "~5.6.2",
    "typescript-eslint": "^8.18.2",
    "vite": "^6.0.6",
    "vite-tsconfig-paths": "^5.1.4"
  }
}

Below are my build settings

-I have tried re-installing node modules but did not work, i tried manually changing “vite”: “^6.0.6”, to be in dependencies instead of devdependencies but did not work

Hi, Aaron! Welcome to the Vercel Community :wave:

The error you’re encountering (“sh: line 1: vite: command not found”) suggests that Vercel can’t find the Vite executable during the build process. This is likely because Vite is listed as a devDependency in your package.json, and Vercel may not be installing devDependencies by default during deployment.

Could you try moving Vite from devDependencies to dependencies in your package.json?

{
  "dependencies": {
    // ... other dependencies ...
    "vite": "^6.0.6"
  },
  "devDependencies": {
    // ... other dev dependencies ...
    // Remove the "vite" entry from here
  }
}

Then update your build command in Vercel. Instead of using vite build directly, use:

npm run build

This change ensures that the build script from your package.json is used, which includes both the TypeScript build and Vite build steps.

After making these changes:

  1. Commit and push these updates to your Git repository.
  2. Vercel should automatically trigger a new deployment.

Let us know how you get on!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.