serve -s build specify port number
Asked Answered
D

2

28

I'm trying to serve a react-app's build folder from a DigitalOcean droplet.

After I run yarn build, I get told by the script to run

yarn global add serve serve -s build

However, when I run serve -s build, It say's it's running on http://localhost:5000. I would like it run on localhost:3000 instead, as I have another server running on port 5000. How can i specify the port number such that serve -s build runs on port 3000?

Dendrite answered 7/10, 2018 at 20:42 Comment(1)
You can use the -l option (lowercase L). serve -l 3000 -s buildFp
I
65

From typing serve --help, I found

-l, --listen listen_uri            
Specify a URI endpoint on which to listen

For TCP ports on hostname "localhost":

$ serve -l 1234

In your case, you can just use

serve -l 3000 -s build

to specify that you want to serve the app on port 3000

Imparadise answered 8/10, 2018 at 6:54 Comment(0)
C
0

To Run your build code on a different port, use the command given below


serve -l 3000 -s build


Here, -l denotes the port number on which port you want to run your code, and -s denotes which file you want to serve.

Cortez answered 7/7, 2024 at 11:22 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.