node.js - 通过 cmd 使用“并发”来测试 API,但我收到错误
问题描述
我是初学者学习 React js。我已经实现了一个 REST API ( https://jsonplaceholder.typicode.com/ )
我使用“并发”使用“npm run start:dev”同时运行两个脚本,但是在执行此操作时出现错误。
下面给出的是我的 package.json 文件
{
"name": "myproj",
"version": "0.1.0",
"private": true,
"dependencies":
{
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"axios": "^0.21.1",
"bootstrap": "^4.6.0",
"json-server": "^0.16.3",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.2",
"web-vitals": "^1.0.1"
}
"scripts":
{
"start": "react-scripts start",
"json-server": "json-server --watch db.json --port 3001",
"start:dev": "concurrently \"npm start\" \"npm run json-server\"",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig":
{
"extends":
[
"react-app",
"react-app/jest"
]
},
"browserslist":
{
"production":
[
">0.2%",
"not dead",
"not op_mini all"
],
"development":
[
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
我得到的错误
D:\FirstReact\myproj>npm start
> myproj@0.1.0 start D:\FirstReact\myproj
>concurrently "npm start" "npm run json-server"
code ELIFECYCLE
npm ERR! errno 1
npm ERR! myproj@0.1.0 start: `react-scripts start:`concurrently "npm run json- server"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myproj@0.1.0 start script.
npm ERR! This is probably not a problem with npm.There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Sony\AppData\Roaming\npm-cache\_logs\2021-02-24T13_50_08_231Z-debug.log
请告诉我如何解决此错误
这是错误错误图像的图像
这是我的项目结构的图像我的项目结构
解决方案
推荐阅读
- nginx - Nginx 不传递 NodeJS 服务器的响应标头
- ansible - Ansible:通过 hostvars[inventory_hostname].host_name 总结节点任务结果
- redis - 如何在前端获取 socket.on 函数?事件被触发和处理。我正在使用 socket.io、NodeJS 服务器和 Redis.io
- r - 克里格中的“CRS 对象有注释,在输出中丢失”
- python-2.7 - 恢复 python 模块
- flutter - Flutter:导航离开时如何关闭 SnackBar?
- javascript - JavaScript 嵌套数组不能使用值?
- python - 在Python中将二元运算符重载为一元
- r - R MSM 包:Q 矩阵对于不同的协变量值是相同的,即使转换率不同
- c# - 在 PackageManagerConsole 中添加迁移时,EF Core IEntityTypeConfiguration 类中未命中断点