PORT=5000 react-scripts start 'PORT' 不被识别为内部或外部命令、可操作程序或批处理文件

问题描述 投票:0回答:2

在 Windows 上测试 -

我有一个在默认 localhost:3000 上运行的 React 前端,我还需要在 localhost:5000 上运行管理员,但是当我 npm start admin 时,我得到:

[电子邮件受保护]开始

PORT=5000 个反应脚本启动

“PORT”不被识别为内部或外部命令, 可运行的程序或批处理文件。

我有 admin .env

REACT_APP_API_URL=http://localhost:8000

前端.env

REACT_APP_API_URL=http://localhost:8000 REACT_APP_ADMIN_URL=http://localhost:5000 REACT_APP_URL=http://localhost

如何让管理员编译/加载并指定端口 5000?

在管理中 - 在 package.json 中尝试更改 - “开始”:“反应脚本开始”, 而不是“开始”:“PORT = 5000反应脚本开始”, 这得到—— 端口 3000 上已在运行某些内容。 您想在另一个端口上运行该应用程序吗? ...是的..在本地主机上加载:3001

加载页面但不起作用(无法登录)

尝试改变 "start": "PORT=5000 反应脚本启动", 到 "start": "PORT=5000 && 反应脚本启动", 无法加载

reactjs localhost port
2个回答
0
投票

修复者:

管理>编辑:package.json

将-“start”:“PORT = 5000 react-scripts start”更改为“start”:“react-scripts start”

保存

并编辑 admin> .env - 如下所示:

端口=5000

REACT_APP_API_URL=http://localhost:8000

保存

管理> npm开始

管理页面现在加载在 http://localhost:5000/ 并登录工作


0
投票

在 package.json 文件中找到这个,

然后改成这样,

“start”:“react-scripts start”,问题已修复

© www.soinside.com 2019 - 2024. All rights reserved.