a year ago
I'm trying to deploy the client-side of my app which is a React site. I've installed the `serveupdated my scripts in package.json:
16 Replies
a year ago
Sorry, I didn't mean to submit that (and can't edit it). Here it is again.
I'm trying to deploy the client-side of my app which was built with create-react-app
. Per instructions here - https://help.railway.app/project-help/f9v3gkPQRy4UShk5SnoPDH/getting-your-create-react-app-running-on-railway/qHRsgxa5n57xLp1yVgk9fP - I've installed the serve
Node package and updated my package.json -
"scripts": {
"start": "serve build -s -n -L -p $PORT",
"dev": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
I also added a variable in the client process NODE_ENV=production
because no matter what, it seems to think the env is development. This is from the logs:
yarn run v1.22.19
$ react-scripts start
/bin/sh: 1: react-scripts: not found
error Command failed with exit code 127.
I'm not sure why it's running that - it should be running yarn run start
which will run serve
. Any suggestions on how to get it to run serve
?
a year ago
could be that the start command is being overwritten somewhere, check the start command in the service settings.
a year ago
Thank you Brody - I don't have a Custom Build Command set.
a year ago
Sorry - no I didn't have any custom commands. But I just added a custom start command - yarn run start
- now I'm getting the error
yarn run v1.22.19
$ serve build -s -n -L -p $PORT
/bin/sh: 1: serve: not found
error Command failed with exit code 127.
but serve
is definitely a dependency: "serve": "^14.2.1",
I didn't see anything in the documentation, but build
is still
"build": "react-scripts build",
so that might be the issue. I guess I can change that to use serve
as well
a year ago
serve is an npm package, it would need to be part of your dependencies.
edit, could you share your repo?
a year ago
Yes, it is a dependency. The snipped was from my package.json. The repo's private, but I can add you as a collaborator if you like.
a year ago
Well, it's making me add a seat since it's an enterprise account. I created a gist with the package.json of the client app -> https://gist.github.com/scookdev/48bdfb505036affdc3a023b5a9f9e880
a year ago
I tried but with an enterprise account you have to add a seat to add a collaborator, which I don't want to do. I'm going to see if I can take the repo out of the account, that way I can add you.
a year ago
OK, done - sent you an invite
a year ago
you have a Dockerfile
Railway will always use one if present, It runs yarn dev
.
renamed the Dockerfle
to [Dockerfile.dev](Dockerfile.dev)
or similar.
also, you may be interested in a better / more efficient method of serving your frontend app.
https://github.com/brody192/create-react-app-starter
This example repo uses caddy to serve the client site, its far less resource intensive compared to serve
all you should need to do is copy the nixpacks.toml and Caddyfile from that repo into your client folder, and remove the custom start command from your service settings
Status changed to Solved railway[bot] • about 1 year ago
a year ago
That's great - thanks so much, Brody.