R
Railway9mo ago
JoshOnX

my react vite app is failing

when i push it fails
Solution:
I've created a vite + react template to demonstrate how I would go about deploying a static frontend CSR app like react, that can be found here https://github.com/brody192/vite-react-template making your own app deployable should be as simple as copying the nixpacks.toml and Caddyfile from that repo into your repo. let me know if that works for you!...
Jump to solution
29 Replies
Percy
Percy9mo ago
Project ID: b81bf663-ab4b-4572-b559-1536c49bef71
JoshOnX
JoshOnX9mo ago
b81bf663-ab4b-4572-b559-1536c49bef71
Brody
Brody9mo ago
are you using a caddyfile?
JoshOnX
JoshOnX9mo ago
sorry for the late response @brody192 i had to confirm and ask the enineer in charge but he said no what do u think i should do it a vite app
Floris
Floris9mo ago
whats the error? or log
JoshOnX
JoshOnX9mo ago
react vite hold on lemme screeenshot
Floris
Floris9mo ago
yes as react vite is just the framework im guessing
JoshOnX
JoshOnX9mo ago
yea
JoshOnX
JoshOnX9mo ago
No description
Floris
Floris9mo ago
ah ! go to your deployment and then to settings
JoshOnX
JoshOnX9mo ago
okay
Floris
Floris9mo ago
and then theres a field called start command
Floris
Floris9mo ago
No description
JoshOnX
JoshOnX9mo ago
yea i put "npm run dev " but it was still failing what should i put
Floris
Floris9mo ago
ahh! because the dev is your local dev server
JoshOnX
JoshOnX9mo ago
what should i write @morpheus9071
Floris
Floris9mo ago
you have npm, No yarn right?
JoshOnX
JoshOnX9mo ago
npm
Floris
Floris9mo ago
probably
npm run build
npm run build
or
vite build
vite build
show me your package.json in your repo that should contain stuff like this usually
JoshOnX
JoshOnX9mo ago
{ "name": "emetric", "private": true, "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview" }, "dependencies": { "@headlessui/react": "^1.7.17", "@heroicons/react": "^2.0.18", "@react-three/drei": "^9.84.2", "@react-three/fiber": "^8.14.2", "@types/three": "^0.156.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.16.0", "react-select": "^5.7.5", "three": "^0.156.1" }, "devDependencies": { "@types/react": "^18.2.15", "@types/react-dom": "^18.2.7", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "@vitejs/plugin-react": "^4.0.3", "autoprefixer": "^10.4.15", "eslint": "^8.45.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.3", "postcss": "^8.4.30", "tailwindcss": "^3.3.3", "typescript": "^5.0.2", "vite": "^4.4.5" } }
Floris
Floris9mo ago
oh ok yeah
npm run build
npm run build
should do the job it'll compile all your TS code and then it should execute vite build itself
JoshOnX
JoshOnX9mo ago
hmm okay lemme do that thanks boss
Floris
Floris9mo ago
yessir noworries bro
Brody
Brody9mo ago
Morpheus, I really do appreciate the assistance but unfortunately that isn't the proper solution OP, when you're online give me a holler
JoshOnX
JoshOnX9mo ago
hey am online it still not working out @Brody i test it in vercel it worked easyly
Brody
Brody9mo ago
yes vercel is purpose built for front end deployment, at a high level, they have a bunch of auto adapters that will deploy your site for a production environment depending on the frameworks in use. railway is not really purpose built for anyone one specific task and thus it will run your code as is, and as is, your code is not suited for a production deployment but since railway can deploy a wider range of applications you can of course prepare your app for railway to deploy it in a suitable way
Solution
Brody
Brody9mo ago
I've created a vite + react template to demonstrate how I would go about deploying a static frontend CSR app like react, that can be found here https://github.com/brody192/vite-react-template making your own app deployable should be as simple as copying the nixpacks.toml and Caddyfile from that repo into your repo. let me know if that works for you!
JoshOnX
JoshOnX9mo ago
thanks a thon it worked like magic i have tested it thanks brody
Brody
Brody9mo ago
awesome, glad I could help