R
Railway•2y 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•2y ago
Project ID: 0de2004b-a959-415e-ab35-f0522f3f8ac0
Brody
Brody•2y ago
please send your repo
Lukoolios
LukooliosOP•2y 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•2y 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
LukooliosOP•2y 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•2y 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
LukooliosOP•2y 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•2y ago
no, not global, install serve into the project
Lukoolios
LukooliosOP•2y ago
ok done
Brody
Brody•2y 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
LukooliosOP•2y ago
ah i see that now, corrected
Brody
Brody•2y 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
LukooliosOP•2y 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•2y 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
LukooliosOP•2y ago
completed
Brody
Brody•2y ago
okay now I'm the service settings, set the root to /seeme-frontend
Lukoolios
LukooliosOP•2y 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•2y ago
does it need the backend to populate?
Lukoolios
LukooliosOP•2y 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•2y 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
LukooliosOP•2y ago
is that within the env file? or eliminate the env and just reference in the app?
Brody
Brody•2y ago
in the app
Lukoolios
LukooliosOP•2y ago
so i need to add another service for this project. ok, is that done through the settings? got it
Brody
Brody•2y ago
in the same project there a plus button in the top right
Lukoolios
LukooliosOP•2y ago
ahh ok, database options dont include sanity, should it just be the same repo but root set to the backend?
Brody
Brody•2y ago
oh sanity is a database? yeah for databases you'll need to use one of the databases railway provides
Lukoolios
LukooliosOP•2y ago
well crap
Brody
Brody•2y ago
unless sanity can store it's data into a database railway provides
Lukoolios
LukooliosOP•2y 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•2y ago
use strapi?
Want results from more Discord servers?
Add your server