问题描述
我正在尝试从 DigitalOcean droplet 提供 react-app 的构建文件夹.
I'm trying to serve a react-app's build folder from a DigitalOcean droplet.
运行 yarn build
后,脚本告诉我运行
After I run yarn build
, I get told by the script to run
yarn 全局添加服务服务 -s 构建
但是,当我运行 serve -s build
时,它说它在 http://localhost 上运行:5000.我希望它在 localhost:3000 上运行,因为我有另一台服务器在端口 5000 上运行.如何指定端口号,以便 serve -s build
在端口 3000 上运行?
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?
推荐答案
从输入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
指定您要在端口 3000 上提供应用程序
to specify that you want to serve the app on port 3000
这篇关于serve -s build 指定端口号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!