📅  最后修改于: 2023-12-03 15:38:59.038000             🧑  作者: Mango
在创建一个新的 React 应用程序时,有时会遇到以下警告消息:
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/core": "7.13.15"
Don't try to install it manually: your package manager does it automatically.
However, a different version of "@babel/core" was detected higher up in the tree:
/path/to/your/project/node_modules/@babel/core (version: 7.14.6)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
这是由于在项目中有一个与 React 脚本不兼容的 "@babel/core" 版本。为了解决这个问题,通常的解决方法是使用 npm 或 yarn 操作来升级或降级对应的依赖项版本。
但是,如果你确实想忽略这个警告消息,并继续使用当前的依赖版本,可以如警告消息所示,在项目的 .env 文件中添加 "SKIP_PREFLIGHT_CHECK=true"。
SKIP_PREFLIGHT_CHECK=true
但需要注意的是,这样可能会引起其他问题。所以建议在使用此方法前,检查自己是否真的需要这样做,以及能否通过其他方式解决当前的问题。