babel-jest 版本问题运行不了项目
来源:2-3 【项目启动】使用create-react-app快速搭建React

海洋饼干ZYF
2021-05-19
babel-jest 版本问题运行不了项目, 跟着课走啪一下很突然就运行不了了.
yarn run v1.22.5
$ react-scripts start
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:
“babel-jest”: “^26.6.0”
Don’t try to install it manually: your package manager does it automatically.
However, a different version of babel-jest was detected higher up in the tree:
C:\Users\Lenovo\node_modules\babel-jest (version: 24.9.0)
尝试了网上的方法把版本改到 26.6.0 也不行, 不知道到底出了什么问题,
尝试创建新的项目也是报这个错.
这是让人头大~
2回答
-
海洋饼干ZYF
提问者
2021-05-22
这个是因为父级上还有一个node_modules,里面的babel-jest 是24.9.0,项目运行时继承了父级里的24.9.0而没有使用项目中的26.6.0, 只要把父级(提示的C:\Users\Lenovo\node_modules\babel-jest)这个node_modules删掉就好了, 只是卸载并重新安装babel-jest是没用的.
10 -
阿莱克斯刘
2021-05-22
同学不要着急,先尝试一下删除整个node_moduels文件夹,然后重新打开编辑器,然后重新安装依赖(npm install)。如果还不行,可以试试删除package-lock.json文件,然后再执行上述步骤。
一般情况下应该是能解决问题的,如果还不行,请把代码发给我,我帮你看看。382231334@qq.com,发代码前通知我一声,以免我遗漏。
112021-05-22
相似问题