【发布时间】:2020-03-02 21:55:37
【问题描述】:
每当我创建一个反应应用程序并尝试启动它时,我都会收到此错误
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:
"webpack": "4.41.5"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:
C:\Users\david\node_modules\webpack (version: 4.41.0)
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 a(n) .env file in your project.
That will permanently disable this message but you might encounter other issues.
我当前的解决方案是将SKIP_PREFLIGHT_CHECK=true 添加到 .env 文件中,但我想普遍解决此问题,因此我不必为我创建的每个 react 应用程序都这样做。
该错误比我发布的要长,它提供了有关如何修复该特定反应应用程序的建议,但没有一个解决方案有效
这是 package.json
{
"name": "dev-chat",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.1",
"@testing-library/user-event": "^7.2.1",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-scripts": "3.4.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
【问题讨论】:
-
我会尝试全局安装。
npm install -g webpack@4.41.5 -
请提供您的
package.json文件。 -
@stackoverflow-newbie 错误比我发布的要长,它提供了有关如何修复该特定反应应用程序的建议,但没有一个解决方案有效
-
卸载全球版本。
-
@crashmstr 你能详细说明一下吗?