R
Railway12mo ago
Hatim

React app deployment issues

Hey all, using ci/cd I deployed my React app but getting errors (failed deployment). this is the error:
31.70 Node.js configure: Found Python 3.11.5…
Dec 06 18:56:17
31.70 Please use python3.10 or python3.9 or python3.8 or python3.7 or python3.6 or python3.5 or python2.7.
31.70 Node.js configure: Found Python 3.11.5…
Dec 06 18:56:17
31.70 Please use python3.10 or python3.9 or python3.8 or python3.7 or python3.6 or python3.5 or python2.7.
the app is React, so it's a Node app, why does it require python3.10? how can I fix this issue? and this is the package.json content attached thanks
39 Replies
Percy
Percy12mo ago
Project ID: bb25496b-1a53-4b7d-a1c6-1ff5c4c025bb
Hatim
Hatim12mo ago
bb25496b-1a53-4b7d-a1c6-1ff5c4c025bb
maddsua
maddsua12mo ago
Hi! Just to be clear, can you share what setup is railway trying to use? (it's that small table in the first lines of the Deploy log) To me it looks like it autodetects the wrong provider
Brody
Brody12mo ago
please use this to send your build logs https://bookmarklets.up.railway.app/log-downloader/
Hatim
Hatim12mo ago
@maddsua [Region: us-west1] ============== Using Nixpacks ============== context: 3b47e39ba0d248de10ac14cc8d70e062 ╔══════════════ Nixpacks v1.19.0 ═════════════╗ ║ setup │ nodejs_14, yarn-1_x ║ ║─────────────────────────────────────────────║ ║ install │ yarn install --frozen-lockfile ║ ║─────────────────────────────────────────────║ ║ build │ yarn run build ║ ║─────────────────────────────────────────────║ ║ start │ yarn run start ║ ╚═════════════════════════════════════════════╝
Brody
Brody12mo ago
^ but node 14 is not supported anymore, please use node 18
Hatim
Hatim12mo ago
ok
Hatim
Hatim12mo ago
same with Node 18
Brody
Brody12mo ago
can you share your repo?
Hatim
Hatim12mo ago
yup. give your github email or username
Brody
Brody12mo ago
brody192
Hatim
Hatim12mo ago
sent i am on the staging branch
Brody
Brody11mo ago
@Hatim what version of node and npm are you using locally?
Hatim
Hatim11mo ago
I have just forced replaced the code to the latest running commit on 2022, node -v v16.13.0 npm -v 8.1.0
Brody
Brody11mo ago
are you able to build the code in staging locally?
Hatim
Hatim11mo ago
i thin it works on Node 18 only... let me double check here what i did: i updated the staging code node 16 and npm 8 works locally fine but when i deploy it fails node 18 shows conflicts with webpack version
Brody
Brody11mo ago
you where able to build your site locally with node 16?
Hatim
Hatim11mo ago
yes
Brody
Brody11mo ago
can you send me a link to the repo again?
Hatim
Hatim11mo ago
https://github.com/hatimmakki/hatim-blog-client/ "node": "16.20.2", "npm": "10.2.5" this works locally only please pull the latest code
Brody
Brody11mo ago
do you use yarn or npm when building locally?
Hatim
Hatim11mo ago
npm
Brody
Brody11mo ago
and now your local version of node is 16.20.2?
Hatim
Hatim11mo ago
yes
Hatim
Hatim11mo ago
deployed for you?
Brody
Brody11mo ago
i used a dockerfile but yeah, im seeing a 400 error on an api request, but thats something youd need to fix in your code otherwise, does that look fine?
Brody
Brody11mo ago
copy these two files into your staging branch and deploy from that branch, thats all i did
Hatim
Hatim11mo ago
oh i can modify Docker? that's great
Brody
Brody11mo ago
you can put a Dockerfile in your repo and railway will build with that, I wouldn't call that modifying docker but give those a try and let me know how it goes
Hatim
Hatim11mo ago
ok, thanks... will railway run the build command as in the project settings? because i don't see any build commands in the Dockerfile oh sorry found it
Brody
Brody11mo ago
the dockerfile handles it all, please don't set any build or start commands yourself anywhere
Hatim
Hatim11mo ago
Hi.. I realised the environmental variables from the project's "variables" tab are not used by this deployment. any idea how can I use that variables in the code?
Brody
Brody11mo ago
yes I do, sorry for not mentioning it. so first all your variables would need to be prefixed with REACT_APP_ though I'm sure they already are, then in the dockerfile you need to reference them to bring them into the build stage. if you had a variable named REACT_APP_BACKEND_URL for example, you would need to add a line with ARG REACT_APP_BACKEND_URL under the first FROM directive in the dockerfile, and so on for all the variables your app needs, heres an example https://docs.railway.app/guides/dockerfiles#using-variables-at-build-time
Hatim
Hatim11mo ago
so, in this example, with only 1 line under FROM, will bring the env variable from Railway to this project? so i can access it using process.env.REACT_APP_BACKEND_URL
Brody
Brody11mo ago
correct, you just continue adding lines with ARG for all variables needed you dont need to put them here https://github.com/hatimmakki/hatim-blog-client/blob/ef9cbdb75719e3ac8a5c3b8fd4c3deccbafd1e79/Dockerfile#L23-L26 at this point in the build the variables have already been "baked" into the built website files
Hatim
Hatim11mo ago
oh, ok thanks.. so only after the First FROM
Want results from more Discord servers?
Add your server