React + Vite Deploy With Error: sh: line 1: vite: command not found

Build and run successfully in localhost, but can’t be built/deployed with vercel

Build Logs

[15:21:59.021] Running build in Washington, D.C., USA (East) – iad1
[15:21:59.153] Cloning GitHub - ZlatanCN/chat_with_me (Branch: main, Commit: 7f656c6)
[15:21:59.502] Previous build cache not available
[15:21:59.526] Cloning completed: 372.37ms
[15:21:59.848] Running “vercel build”
[15:22:00.297] Vercel CLI 37.1.2
[15:22:00.918] Skipping “install” command…
[15:22:01.110]
[15:22:01.111] > chat-with-me@1.0.0 build
[15:22:01.111] > npm install && npm install --prefix frontend && npm run build-frontend
[15:22:01.111]
[15:22:08.997]
[15:22:08.997] added 147 packages, and audited 148 packages in 8s
[15:22:08.998]
[15:22:08.998] 19 packages are looking for funding
[15:22:08.998] run npm fund for details
[15:22:08.999]
[15:22:08.999] found 0 vulnerabilities
[15:22:17.871]
[15:22:17.871] added 163 packages, and audited 165 packages in 9s
[15:22:17.872]
[15:22:17.872] 8 packages are looking for funding
[15:22:17.873] run npm fund for details
[15:22:17.874]
[15:22:17.875] found 0 vulnerabilities
[15:22:18.017]
[15:22:18.017] > chat-with-me@1.0.0 build-frontend
[15:22:18.018] > cd frontend && npm run build
[15:22:18.018]
[15:22:18.154]
[15:22:18.156] > frontend@0.0.0 build
[15:22:18.157] > vite build
[15:22:18.157]
[15:22:18.160] sh: line 1: vite: command not found
[15:22:18.183] Error: Command “npm run build” exited with 127
[15:22:18.505]

Repository

ZlatanCN/chat_with_me (github.com)

Hi, @zlatancn!

Thanks for providing your repository, this helps a lot. :smile:

  1. Your frontend/package.json looks correct!
  2. Make sure your root package.json has the correct build script:
"build": "npm install && cd frontend && npm install && npm run build"
  1. Verify Vercel project settings. It should be something:
  • Framework Preset: Vite
  • Build Command: npm run build
  • Output Directory: frontend/dist

  1. Check that frontend/.gitignore includes node_modules and dist.
  2. Commit and push any changes, then try deploying again.

Can you give that a go?

I also wanted to make sure that you were aware of Vercel CLI. Might be helpful when testing what deployment would be like before deploying and catching errors!

Thank you! I have tried all things you list, but it still failed for the same issue.

.gitignore

package.json

setting

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