[英]Conflict between react script and jest version 24.7.1
After creating a react app with 'create-react-app' things have been successful till now. 用'create-react-app'创建一个反应应用程序后,事情一直很成功。 I have made a working react project.
我做了一个有效的反应项目。 But now that I'm looking to implement unit testing with jest.
但现在我正在寻求用开玩笑实现单元测试。
Using npm to install: 'npm install --save-dev jest' Then running: npm ls jest I notice that the react-script is looking for a jest version that is significantly older. 使用npm安装:'npm install --save-dev jest'然后运行:npm ls jest我注意到react-script正在寻找一个非常老的开玩笑版本。
package.json: 的package.json:
"dependencies": {
"react": "^16.8.1",
"react-dom": "^16.8.1",
"react-redux": "^6.0.0",
"react-scripts": "2.1.5",
"redux": "^4.0.1"
},
"devDependencies": {
"jest": "^24.7.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest",
"eject": "react-scripts eject"
}
npm ls jest result: npm ls jest结果:
+-- jest@24.7.1
`-- react-scripts@2.1.5
`-- jest@23.6.0
npm start error: npm开始错误:
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix
locally.
The react-scripts package provided by Create React App requires a
dependency:
"jest": "23.6.0"
Don't try to install it manually: your package manager does it
automatically.
However, a different version of jest was detected higher up in the tree:
C:\Users\userName\sample js codes\redux\songs\node_modules\jest (version:
24.7.1)
Is there a solution to solve this dependency version issue? 有没有解决这个依赖版本问题的解决方案?
Create-react-app comes with Jest built-in, there is no need to install it additionally. Create-react-app内置Jest,无需另外安装。
You have a version conflict now because you installed it additionally. 您现在有版本冲突,因为您另外安装了它。 To fix it, revert your changes to package.json .
要修复它,请将更改还原到package.json 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.