【发布时间】:2021-02-06 09:03:29
【问题描述】:
我有多个反应应用程序,例如一个父应用程序,在父应用程序中,我还有两个应用程序在不同的端口上运行,父应用程序在 3000 端口上运行,第一个孩子在 3005 端口上运行,第二个孩子在 4000 端口上运行.我在下面给出的脚本部分的 package.json 文件中做了一些配置
父应用有
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"odmit": "npm start odmit_view",
"moderator": "npm start --prefix moderator",
"monitor": "npm start --prefix monitor",
"dev": "concurrently \"npm run odmit\" \"npm run moderator\" \"npm run monitor\""
},
第一个孩子有 package.json 是
"scripts": {
"start": "PORT=4000 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
第二个孩子有 package.json
"scripts": {
"start": "PORT=3005 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
当我使用命令npm run dev 在 ubuntu 上运行它时,这会很好。当我在 Windows 中运行相同的命令时,它会给我一个无法识别此端口的波纹管错误。
'PORT' is not recognized as an internal or external command,
[2] operable program or batch file.
[2] npm ERR! code ELIFECYCLE
[2] npm ERR! errno 1
[2] npm ERR! monitor@0.1.0 start: `PORT=4000 react-scripts start`
[2] npm ERR! Exit status 1
[2] npm ERR!
[2] npm ERR! Failed at the monitor@0.1.0 start script.
[2] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1]
[1] > moderator@0.1.0 start D:\odmit_view\moderator
这是什么问题,谁能帮帮我。
【问题讨论】:
标签: reactjs npm environment-variables create-react-app