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