Reactjs 创建react应用程序后尝试使用npm start返回错误

Reactjs 创建react应用程序后尝试使用npm start返回错误,reactjs,npm,webpack,Reactjs,Npm,Webpack,每当我创建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:

每当我创建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:

  "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\u PREFLIGHT\u CHECK=true
添加到.env文件中,但我想普遍解决这个问题,这样我就不必为我创建的每个react应用程序都这样做

这个错误比我发布的要长,它给出了如何修复特定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"
    ]
  }
}


我以前在我的一个项目中见过这种情况,这个错误有时意味着你正在另一个react应用程序中安装react应用程序(具有不同的网页版本)

因为我看到您的node_模块安装路径位于系统根目录的users文件夹中。您可能无意中在目录中创建了react应用程序


删除您在C:\Users\david中创建的react应用程序,并通过运行以下命令将其重新安装到另一个目录(如C:\Users\david\desktop)中:
npx create react app[您的项目名称]
(对于项目名称,请删除方括号)。

我将尝试全局安装<代码>npm安装-gwebpack@4.41.5请提供您的
包.json
文件。@stackoverflow newbie错误比我发布的要长,它给出了如何修复特定react应用程序的建议,但没有一个解决方案可以卸载全局版本。@Crashstr您能详细说明吗?