R
Railway

✋|help

How do I hook up my frontend correctly./

AAda238/24/2023
I am able to deploy my backend but my frontend is not working yet.

Error:
#8 [4/5] RUN  npm run build

 

#8 0.318 /bin/bash: line 1: npm: command not found

#8 ERROR: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 127

-----

> [4/5] RUN  npm run build:

0.318 /bin/bash: line 1: npm: command not found

-----

 

Dockerfile:15

-------------------

13 |     # build phase

14 |     COPY . /app/.

15 | >>> RUN  npm run build

16 |

17 |

-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 127

 

Error: Docker build failed
AAda238/24/2023
3b4c3c14-6b11-4e8a-8f52-bb11ff2f2554
repo: https://github.com/hannarosenfeld/vault-manager
Bbrody1928/24/2023
refresh me please, screenshot of your railway project?
AAda238/24/2023
Bbrody1928/24/2023
do you have the root directory set to /frontend?
AAda238/24/2023
Bbrody1928/24/2023
and if you have any build or start commands set in the service settings, please clear them
AAda238/24/2023
yes
sorry i just saw i didn't it must have not saved. set it to /frontend now
cleared build / start commands
Bbrody1928/24/2023
please copy the Caddyfile and nixpacks.toml files from this repo https://github.com/brody192/create-react-app-starter into your frontend folder
AAda238/24/2023
ok done and pushed. redeploying now
#19 ERROR: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 1

-----

> [stage-0 12/15] RUN --mount=type=cache,id=s/fbd4d67e-9585-4de6-87a7-920ec77582e8-node_modules/cache,target=/app/node_modules/.cache npm run build:

14.21   Line 4:3:   'BrowserRouter' is defined but never used                                                                    no-unused-vars

14.21   Line 7:3:   'Navigate' is defined but never used                                                                         no-unused-vars

14.21   Line 15:8:  'Navigation' is defined but never used                                                                       no-unused-vars

14.21   Line 31:6:  React Hook useEffect has a missing dependency: 'isLoaded'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

14.21   Line 33:9:  'sessionUser' is assigned a value but never used                                                             no-unused-vars

14.21

14.21 src/store/index.js

14.21   Line 5:8:  'logger' is defined but never used  no-unused-vars

14.21

14.21

-----

 

Dockerfile:30

-------------------

28 |     # build phase

29 |     COPY . /app/.

30 | >>> RUN --mount=type=cache,id=s/fbd4d67e-9585-4de6-87a7-920ec77582e8-node_modules/cache,target=/app/node_modules/.cache npm run build

31 |

32 |     # fmt phase

-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 1

 

Error: Docker build failed
Bbrody1928/24/2023
you have a bunch of warnings and they are being treated as errors, you have two options, fix the warnings, or ignore the warnings and fix them later
AAda238/24/2023
I'll fix them later, they are referencing things I will use later
Bbrody1928/24/2023
gotcha, set a service variable CI = false
AAda238/24/2023
done, getting this error now:

#18 ERROR: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 1

-----

> [stage-0 12/15] RUN --mount=type=cache,id=s/fbd4d67e-9585-4de6-87a7-920ec77582e8-node_modules/cache,target=/app/node_modules/.cache npm run build:

18.68   Line 4:3:   'BrowserRouter' is defined but never used                                                                    no-unused-vars

18.68   Line 7:3:   'Navigate' is defined but never used                                                                         no-unused-vars

18.68   Line 15:8:  'Navigation' is defined but never used                                                                       no-unused-vars

18.68   Line 31:6:  React Hook useEffect has a missing dependency: 'isLoaded'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

18.68   Line 33:9:  'sessionUser' is assigned a value but never used                                                             no-unused-vars

18.68

18.68 src/store/index.js

18.68   Line 5:8:  'logger' is defined but never used  no-unused-vars

18.68

18.68

-----

 

Dockerfile:30

-------------------

28 |     # build phase

29 |     COPY . /app/.

30 | >>> RUN --mount=type=cache,id=s/fbd4d67e-9585-4de6-87a7-920ec77582e8-node_modules/cache,target=/app/node_modules/.cache npm run build

31 |

32 |     # fmt phase

-------------------

ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm run build" did not complete successfully: exit code: 1

 

Error: Docker build failed
AAda238/24/2023
Bbrody1928/24/2023
uhhhh
redeploy?
AAda238/24/2023
ok doing that now
exact same error after rebuild : /
Bbrody1928/24/2023
can i see the full build logs, use this https://bookmarklet.up.railway.app/log-downloader/
AAda238/24/2023
AAda238/24/2023
that's pretty cool
Bbrody1928/24/2023
thank you 🙂
Bbrody1928/24/2023
Bbrody1928/24/2023
use this in your frontend instead?
AAda238/24/2023
ok done and redeploying now
Bbrody1928/24/2023
what was the removal of BrowserRouter for?
AAda238/24/2023
I wasn't gonna use that one
It worked! Do I need to somehow connected my backend and frontend or are they connected now?
Bbrody1928/24/2023
your frontend will need to know the domain to call for api requests, you can add this as a variable to the frontend service like so
REACT_API_URL = https://${{RAILWAY_SERVICE_VAULT_MANAGER_BACKEND_URL}}
i think i spelt that correctly
i did the same type of thing here as a demo, this would be how that variable would look when in code https://utilities.up.railway.app/env-vars?prefix=REACT_
AAda238/24/2023
thank you!! much appreciated
would i use the domain for the front or backend service ?
when i want to visit my site
Bbrody1928/24/2023
youd need both services to have domains
but you would visit your site from the frontend domain
then your frontend would call your backend via the value from the REACT_API_URL environment variable
AAda238/24/2023
awesome thank you!
Bbrody1928/24/2023
no problem, if you have any more questions, feel free to ask

Looking for more? Join the community!

Recommended Posts
Styling bug on project service usage pageIs there a way I can have Railway restart manually every 2 hours?Pretty self explanatory, I’m running some js codePostgres, Aspnet Core API and Angular WebguiHi guys. I'm new here and getting to know railway! I find it fantastic for us. I am lost. I would lCannot change default provider for environment thats created during GitHub Pull RequestI posted about this a while back (https://discord.com/channels/713503345364697088/112689969354953113expressidkI'm not sure on how to transfer my wiki.js database data to railway.86f37e49-db7c-4b6f-9c3e-71f5447b116a I am either getting a broken wiki.js database that results in Build and deployment is accountable in service consumptionconsider in a context of docker image number of images downloaded and each operation performed in doQuestion about billHello i have a railway acount and i work with my accounting team but they need an tax number identifEnvironment Variable Not foundI am using nodejs as a backend and the config plugin with it to get the access to the Railway envoirERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sockI tried deleting my Railway proc file and getting this error now ERROR: Cannot connect to the DockerNeed wordpress template helpI have this error: Please contact your hosting service and ask them to increase max_input_vars valueCan't login using my emailHi there, I'm trying to login to my account using the magic link, but whenever I do it I get this erDjango Deployment Issue - 503 Error on Railway PlatformHello, I am encountering a 503 error ("Application failed to respond") while deploying my Django apAccessing application results in 502. "upstream connect error or disconnect/reset before headers. "Trying to publish an application to the railway platform. It is a mixture of react, together with soAbout Private networkingHi, I saw Railway has https://docs.railway.app/reference/private-networking Private network domain, refundThe estimated bill is $5, but the actual cost is $11.99, which is much higher than expected. I requeHelloHello, I added cascade = CascadeType.ALL to a OneToMany relationship in my DB. Works locally, but deCannot create code snapshot right nowProject ID `a0e71e1d-430e-45cc-95c5-af153af61c1c` "Cannot create code snapshot right now, please reDeploy my app on Railway (Cost)Hello, Actually I have an API made with Nodejs + Express about Real Estate so I wanna recommendatioHow do you add a worker to a Procfile?It seems that Railway only accepts "web", so how can I add a "worker" to a Procfile?