Vite not found render error

Hello. I am trying to deploy my react-vite app with a sequelize back-end to render and I am getting an error saying that “sh: 1: vite: not found” the structure of my applications is listed below for detail. Seems like the backend installs successfully but it throws an error once trying to build the frontend app. I’ll post the full error below too.

I think its the problem is I’m not telling render how to correctly find the vite.config file even though I input a command in my build file to cd into the frontend before running “npm run build”. Has anyone experienced this problem and know of the proper command? Thank you!

|
|
-backend 
 -- package.json
-frontend
 -- package.json
-package.json

the root package.json has the build command for render

 "scripts": {
    "render-postbuild": "npm install --prefix frontend && cd /opt/render/project/src/frontend && npm run build",
    "install": "npm --prefix backend install backend && npm --prefix frontend install frontend",
    "dev:backend": "npm install --prefix backend start",
    "dev:frontend": "npm install --prefix frontend start",
    "sequelize": "npm run --prefix backend sequelize",
    "sequelize-cli": "npm run --prefix backend sequelize-cli",
    "start": "npm start --prefix backend",
    "build": "npm run build --prefix backend"
  },
Oct 24 02:41:54 PM  ==> Cloning from https://github.com/boromeot/aA-hackathon-project...
Oct 24 02:41:55 PM  ==> Checking out commit dae3eaf399ff0af3cbbf0474f449879549d57394 in branch main
Oct 24 02:41:58 PM  ==> Using Node version 14.17.0 (default)
Oct 24 02:41:58 PM  ==> Docs on specifying a Node version: https://render.com/docs/node-version
Oct 24 02:41:58 PM  ==> Running build command 'npm install && npm run render-postbuild && npm run build && npm run sequelize --prefix backend db:seed:undo:all && npm run sequelize --prefix backend db:migrate:undo:all && npm run sequelize --prefix backend db:migrate && npm run sequelize --prefix backend db:seed:all'...
Oct 24 02:41:59 PM  
Oct 24 02:41:59 PM  > aa-hackathon-project@1.0.0 install /opt/render/project/src
Oct 24 02:41:59 PM  > npm --prefix backend install backend && npm --prefix frontend install frontend
Oct 24 02:41:59 PM  
Oct 24 02:42:10 PM  
Oct 24 02:42:10 PM  > es5-ext@0.10.62 postinstall /opt/render/project/src/backend/node_modules/es5-ext
Oct 24 02:42:10 PM  >  node -e "try{require('./_postinstall')}catch(e){}" || exit 0
Oct 24 02:42:10 PM  
Oct 24 02:42:10 PM  added 218 packages from 214 contributors and audited 359 packages in 10.363s
Oct 24 02:42:10 PM  
Oct 24 02:42:10 PM  20 packages are looking for funding
Oct 24 02:42:10 PM    run `npm fund` for details
Oct 24 02:42:10 PM  
Oct 24 02:42:10 PM  found 0 vulnerabilities
Oct 24 02:42:10 PM  
Oct 24 02:42:17 PM  added 101 packages from 106 contributors and audited 325 packages in 5.73s
Oct 24 02:42:17 PM  
Oct 24 02:42:17 PM  14 packages are looking for funding
Oct 24 02:42:17 PM    run `npm fund` for details
Oct 24 02:42:17 PM  
Oct 24 02:42:17 PM  found 0 vulnerabilities
Oct 24 02:42:17 PM  
Oct 24 02:42:17 PM  up to date in 17.821s
Oct 24 02:42:17 PM  found 0 vulnerabilities
Oct 24 02:42:17 PM  
Oct 24 02:42:17 PM  
Oct 24 02:42:17 PM  > aa-hackathon-project@1.0.0 render-postbuild /opt/render/project/src
Oct 24 02:42:17 PM  > npm install --prefix frontend && cd /opt/render/project/src/frontend && npm run build
Oct 24 02:42:17 PM  
Oct 24 02:42:20 PM  audited 325 packages in 1.892s
Oct 24 02:42:20 PM  
Oct 24 02:42:20 PM  14 packages are looking for funding
Oct 24 02:42:20 PM    run `npm fund` for details
Oct 24 02:42:20 PM  
Oct 24 02:42:20 PM  found 0 vulnerabilities
Oct 24 02:42:20 PM  
Oct 24 02:42:20 PM  
Oct 24 02:42:20 PM  > aa-hackathon-project@0.0.0 build /opt/render/project/src/frontend
Oct 24 02:42:20 PM  > vite build
Oct 24 02:42:20 PM  
Oct 24 02:42:20 PM  sh: 1: vite: not found
Oct 24 02:42:20 PM  npm ERR! code ELIFECYCLE
Oct 24 02:42:20 PM  npm ERR! syscall spawn
Oct 24 02:42:20 PM  npm ERR! file sh
Oct 24 02:42:20 PM  npm ERR! errno ENOENT
Oct 24 02:42:20 PM  npm ERR! aa-hackathon-project@0.0.0 build: `vite build`
Oct 24 02:42:20 PM  npm ERR! spawn ENOENT
Oct 24 02:42:20 PM  npm ERR!
Oct 24 02:42:20 PM  npm ERR! Failed at the aa-hackathon-project@0.0.0 build script.
Oct 24 02:42:20 PM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Oct 24 02:42:20 PM  
Oct 24 02:42:20 PM  npm ERR! A complete log of this run can be found in:
Oct 24 02:42:20 PM  npm ERR!     /opt/render/.cache/_logs/2023-10-24T21_42_20_672Z-debug.log
Oct 24 02:42:20 PM  npm ERR! code ELIFECYCLE
Oct 24 02:42:20 PM  npm ERR! errno 1
Oct 24 02:42:20 PM  npm ERR! aa-hackathon-project@1.0.0 render-postbuild: `npm install --prefix frontend && cd /opt/render/project/src/frontend && npm run build`
Oct 24 02:42:20 PM  npm ERR! Exit status 1
Oct 24 02:42:20 PM  npm ERR!
Oct 24 02:42:20 PM  npm ERR! Failed at the aa-hackathon-project@1.0.0 render-postbuild script.
Oct 24 02:42:20 PM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Oct 24 02:42:20 PM  
Oct 24 02:42:20 PM  npm ERR! A complete log of this run can be found in:
Oct 24 02:42:20 PM  npm ERR!     /opt/render/.cache/_logs/2023-10-24T21_42_20_697Z-debug.log
Oct 24 02:42:20 PM  ==> Build failed 😞

Hi,

There’s a lot going on here, but some common things to check are:

  • That vite is listed in the package.json as you expect.

  • If it’s in the package.json but under devDependencies make sure it is being installed:

    • If you have set NODE_ENV to production, this will be present at build time and won’t install devDependencies (our defaults set it to production only at runtime)

    • You can install devDependencies by either removing NODE_ENV or telling npm install to install them anyway with the --production=false option. (npm-install docs)

Alan

3 Likes

Thank you so much! adding --production=false to my build script helped fix the problem.

full line is "render-postbuild": "npm install --prefix frontend --production=false && cd /opt/render/project/src/frontend && npm run build" for anyone that wants a reference.

3 Likes

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