reactjs - 同时运行两个 npm 命令
问题描述
我已经设置json-server
并成功运行,port-3000
然后运行npm start
它在其他端口上运行3001
。
但我想同时运行两者。我试过并发但没有用。
当我执行此命令时:
$ concurrently "npm start" "json-server --watch ./topPanelData.json"
错误信息:
解决方案
通过这些步骤解决的问题:
使用以下密钥创建
json-server.json
以在不同端口上运行服务器。{ "port": 4000 }
更新启动脚本
package.json
"start": "concurrently \"react-scripts start\" \"json-server ./topPanelData.json\""
只需运行
$ npm start
它会同时在不同的端口上执行json 服务器: http://localhost:4000/topPanelData
反应应用程序: http://localhost:3000/
推荐阅读
- javascript - 通过搜索另一个变量获取 json 变量
- selenium - (并行)使用 TextNG.XML 套件在 TestNG 中进行交叉浏览
- python - R 和 Python 中 Butterworth 滤波器的不同结果
- webpack - 使用 JavaScript 包捆绑/迷你(构建)时,Webpack 正在提升/封装我的代码
- azure - 使用 python sdk 在 azure 中的 linux vm 中运行命令
- rest - 没有 Appserver 的 API 调用
- android - 将数据从 Fragment 返回到 Activity
- jquery - 当空间包含数据列表时仅显示第一部分
- c# - SQL Cube(分析服务)消费
- javascript - 正则表达式在 Node.js/Javascript 中不匹配