gpt4 book ai didi

javascript - react 脚本和 jest 版本 24.7.1 之间的冲突

转载 作者:搜寻专家 更新时间:2023-10-31 23:50:05 24 4
gpt4 key购买 nike

在使用“create-react-app”创建了一个 React 应用程序之后,事情一直很成功。我做了一个工作 react 项目。但是现在我正在 Jest 实现单元测试。

使用 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 结果:

+-- 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

关于javascript - react 脚本和 jest 版本 24.7.1 之间的冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55630841/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com