R
Railway•15mo ago
Lukoolios

Deploying React App with Sanity backend

Project ID: 0de2004b-a959-415e-ab35-f0522f3f8ac0 I am having issues with deployment. I have a React app with a Sanity backend that runs on local but is having issues deploying. Specifically receiving this error: npm WARN config production Use --omit=dev instead. npm ERR! Missing script: "start" npm ERR! npm ERR! Did you mean one of these? npm ERR! npm star # Mark your favorite packages npm ERR! npm stars # View packages marked as favorites npm ERR! npm ERR! To see a list of scripts, run: npm ERR! npm run npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2023-04-27T19_54_41_363Z-debug-0.log I have all dependencies installed and ran npm install on both the front and backend to ensure all were available and verified that the JSON files both have the start script.
30 Replies
Percy
Percy•15mo ago
Project ID: 0de2004b-a959-415e-ab35-f0522f3f8ac0
Brody
Brody•15mo ago
please send your repo
Lukoolios
Lukoolios•15mo ago
GitHub
GitHub - LukeLarson2/vetconnect-social-media-app: Social media plat...
Social media platform concept for active duty and prior military service users only - GitHub - LukeLarson2/vetconnect-social-media-app: Social media platform concept for active duty and prior milit...
Brody
Brody•15mo ago
here is a create react app that's ready for deployment on railway https://github.com/brody192/create-react-app-starter please update your frontend with my start script and also install serve once done, I'll tell you your next step
Lukoolios
Lukoolios•15mo ago
alright, sorry this is my first full stack react app so a bit slow updated the script in the front end json and installed serve currently npm start no longer runs the app locally, so if that right, sweet, if not then I did something wrong
Brody
Brody•15mo ago
railway uses the start script to start your app, the original start command has now moved to the dev command please push your changes so I can review
Lukoolios
Lukoolios•15mo ago
before i commit i just want to make sure ive done this correctly all i needed to do was swap out the scrip in the json for front end and then run npm install --global serve correct?
Brody
Brody•15mo ago
no, not global, install serve into the project
Lukoolios
Lukoolios•15mo ago
ok done
Brody
Brody•15mo ago
it doesn't look like you installed serve as a dependency all you need to do is npm i serve in your frontend app please remove it from the package.json in the root
Lukoolios
Lukoolios•15mo ago
ah i see that now, corrected
Brody
Brody•15mo ago
you are also saving credentials in a .env file, please remove them and regenerate them immediately store credentials in railway, in the service variables tab
Lukoolios
Lukoolios•15mo ago
done, in order to link them from railway to the app, again i appologize new at this still, will that be done via the variable name and then referenced to by {{<variable name here>}}
Brody
Brody•15mo ago
yes railway will inject the service variables as environment variables, and you can reference them the same way that you'd reference any environment variable let me know when you have regenerated those credentials and have added the new credentials to the service variables
Lukoolios
Lukoolios•15mo ago
completed
Brody
Brody•15mo ago
okay now I'm the service settings, set the root to /seeme-frontend
Lukoolios
Lukoolios•15mo ago
done looks like it starts but doesnt populate correctly trying to find solution to make sure i am referencing the variables correctly this is my first time deploying a full stack app so again i apologize for my noob-ness
Brody
Brody•15mo ago
does it need the backend to populate?
Lukoolios
Lukoolios•15mo ago
not for the login screen, the keys are provided in the login.jsx backend just stores the new userprofiles do the variables within railway replace the need for a env file completely? and if so how would i then reference them within the app. I havent found adequate documentation on it yet
Brody
Brody•15mo ago
ah okay because for the backend to run you need to make another service and set the root folder in the settings to be the backend folder you reference them the same way you would in any node environment, process.env.NAME
Lukoolios
Lukoolios•15mo ago
is that within the env file? or eliminate the env and just reference in the app?
Brody
Brody•15mo ago
in the app
Lukoolios
Lukoolios•15mo ago
so i need to add another service for this project. ok, is that done through the settings? got it
Brody
Brody•15mo ago
in the same project there a plus button in the top right
Lukoolios
Lukoolios•15mo ago
ahh ok, database options dont include sanity, should it just be the same repo but root set to the backend?
Brody
Brody•15mo ago
oh sanity is a database? yeah for databases you'll need to use one of the databases railway provides
Lukoolios
Lukoolios•15mo ago
well crap
Brody
Brody•15mo ago
unless sanity can store it's data into a database railway provides
Lukoolios
Lukoolios•15mo ago
dont know if thats possible at this point now im trying reinstate the authentication and its not working😭 ok well fixed that, so i need to find a different way to store backend
Brody
Brody•15mo ago
use strapi?