React版本:LTS系统
重现步骤
运行npx create-react-app my-app --template typescript
检查package.json
当前行为
相关性显示如下:
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.3",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
}
预期行为
"dependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"typescript": "^4.1.2"
}
4条答案
按热度按时间wnavrhmk1#
在此之前,为了保存未来读者的时间:
x1m0n1x
npm install -D @testing-library/jest-dom @testing-library/react @testing-library/user-event @types/jest @types/node @types/react @types/react-dom typescript
个yqyhoc1h2#
我还假设
react-scripts
是一个devDependency。khbbv19g3#
此问题已自动标记为过时,因为它最近没有任何活动.如果没有进一步得活动,它将在5天内关闭.
iugsix8n4#
你好!我在我的申请表上也看到了这个,你能帮我分类一下吗?谢谢!
另外,与安装testing-library/react和jest-dom相关的文档提到我们应该使用“--保存”而不是“--save-dev”,这样做有什么具体的原因吗?