简体   繁体   English

serve -s build 指定端口号

[英]serve -s build specify port number

I'm trying to serve a react-app's build folder from a DigitalOcean droplet.我正在尝试从 DigitalOcean droplet 提供 react-app 的构建文件夹。

After I run yarn build , I get told by the script to run运行yarn build ,脚本告诉我运行

yarn global add serve serve -s build

However, when I run serve -s build , It say's it's running on http://localhost:5000 .但是,当我运行serve -s build ,它说它正在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?我希望它在 localhost:3000 上运行,因为我有另一台服务器在端口 5000 上运行。如何指定端口号,使serve -s build在端口 3000 上运行?

From typing serve --help , I found通过输入serve --help ,我发现

-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指定您要在端口 3000 上为应用程序提供服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM