javascript-React脚本和Jest版本24.7.1之间的冲突

前端之家收集整理的这篇文章主要介绍了javascript-React脚本和Jest版本24.7.1之间的冲突 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

用’create-react-app’创建一个React应用之后,到目前为止,一切都已经成功了.我做了一个工作中的React项目.但是现在,我希望以开玩笑的方式实施单元测试.

使用npm安装:’npm install –save-dev jest’
然后运行:npm ls jest我注意到react-script正在寻找一个明显更旧的jest版本.

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@24.7.1
`-- react-scripts@2.1.5
  `-- jest@23.6.0

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)

解决此依赖性版本问题的解决方案吗?

最佳答案
Create-react-app内置Jest,无需额外安装.

您现在有版本冲突,因为您另外安装了它.
解决此问题,请将您的更改还原为package.json.

原文链接:https://www.f2er.com/js/531279.html

猜你在找的JavaScript相关文章