简体   繁体   English

'npm start' 返回错误:“项目依赖树可能有问题”

[英]'npm start' returns error: "There might be a problem with the project dependency tree"

I'm new to coding and having issues with why I can no longer get React set up correctly.我是编码新手,对为什么我无法再正确设置 React 有疑问。 I struggled with this last week and then finally managed it.上周我为此苦苦挣扎,然后终于成功了。 But now I have had the same issue again and nothing is working.但现在我又遇到了同样的问题,但没有任何效果。

I have a project which I started with npx create-react-app and then when I cd into the project I get this issue:我有一个项目,我从 npx cd npx create-react-app开始,然后当我进入该项目时,我遇到了这个问题:

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.这可能不是 Create React App 中的错误,而是您需要在本地修复的问题。

The react-scripts package provided by Create React App requires a dependency: Create React App 提供的 react-scripts package 需要依赖:

"webpack": "4.29.6" “网络包”:“4.29.6”

Don't try to install it manually: your package manager does it automatically.不要尝试手动安装它:您的 package 经理会自动安装。 However, a different version of webpack was detected higher up in the tree:但是,在树的较高位置检测到不同版本的 webpack:

/Users/aliceparker/node_modules/webpack (version: 4.33.0) /Users/aliceparker/node_modules/webpack(版本:4.33.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 an.env file in your project.如果您希望忽略此检查,请将 SKIP_PREFLIGHT_CHECK=true 添加到项目中的 an.env 文件中。 That will permanently disable this message but you might encounter other issues.这将永久禁用此消息,但您可能会遇到其他问题。

To fix the dependency tree, try following the steps below in the exact order:要修复依赖关系树,请尝试按确切顺序执行以下步骤:

  1. Delete package-lock.json (not package.json.) and/or yarn.lock in your project folder.删除项目文件夹中的 package-lock.json(不是 package.json。)和/或 yarn.lock。
  2. Delete node_modules in your project folder.删除项目文件夹中的 node_modules。
  3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.从项目文件夹中 package.json 文件的依赖项和/或 devDependencies 中删除“webpack”。
  4. Run npm install or yarn, depending on the package manager you use.运行 npm install 或 yarn,具体取决于您使用的 package 管理器。

In most cases, this should be enough to fix the problem.在大多数情况下,这应该足以解决问题。 If this has not helped, there are a few other things you can try:如果这没有帮助,您可以尝试其他一些方法:

  1. If you used npm, install yarn ( http://yarnpkg.com/ ) and repeat the above steps with it instead.如果您使用 npm,请安装 yarn ( http://yarnpkg.com/ ) 并用它重复上述步骤。 This may help because npm has known issues with package hoisting which may get resolved in future versions.这可能会有所帮助,因为 npm 已知 package 提升的问题可能会在未来的版本中得到解决。

  2. Check if /Users/aliceparker/node_modules/webpack is outside your project directory.检查 /Users/aliceparker/node_modules/webpack 是否在您的项目目录之外。 For example, you might have accidentally installed something in your home folder.例如,您可能不小心在主文件夹中安装了一些东西。

  3. Try running npm ls webpack in your project folder.尝试在项目文件夹中运行 npm ls webpack。 This will tell you which other package (apart from the expected react-scripts) installed webpack.这将告诉您其他哪些 package(除了预期的反应脚本)安装了 webpack。

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an.env file in your project.如果没有其他帮助,请将 SKIP_PREFLIGHT_CHECK=true 添加到项目中的 an.env 文件中。 That would permanently disable this preflight check in case you want to proceed anyway.如果您仍然想继续,那将永久禁用此预检检查。

PS We know this message is long but please read the steps above:-) We hope you find them helpful! PS 我们知道这条消息很长,但请阅读上面的步骤:-) 我们希望它们对您有所帮助!

I've followed the steps above.我已经按照上面的步骤操作了。 Still get the issue.仍然得到这个问题。 I've also uninstalled webpack globally and re-installed it.我还全局卸载了 webpack 并重新安装了它。

Here is what my package.json file looks like:这是我的 package.json 文件的样子:

`{
  "name": "ravenous-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-scripts": "3.0.1"
  },
  "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"
    ]
  }
}`

Can anyone kindly guide me through ways to solve this?谁能指导我解决这个问题的方法?
(PS. I tried just creating a new project, but get the same issue...) (PS。我只是尝试创建一个新项目,但遇到了同样的问题......)

In my case, I solved my problem in this way就我而言,我以这种方式解决了我的问题

  1. create a .env at the root of the folder react folder在文件夹react folder的根目录下创建一个.env
  2. type SKIP_PREFLIGHT_CHECK=true inside of .env file.env文件中输入SKIP_PREFLIGHT_CHECK=true
  3. now run in cmd npm start .现在在 cmd npm start中运行。

In the terminal, run:在终端中,运行:

cd ~

Then:然后:

ls

You should see a list of files.您应该会看到一个文件列表。 If node_modules is included in that list (as it appears it should be), you want to delete that folder.如果node_modules包含在该列表中(看起来应该如此),则您要删除该文件夹。 You can do so in the terminal like so:您可以像这样在终端中执行此操作:

rm -rf node_modules

But keep in mind: this will not send the folder to the trash.但请记住:这不会将文件夹发送到垃圾箱。 It will irrevocably delete it.它将不可撤销地删除它。 rm -rf is a powerful command. rm -rf是一个强大的命令。 If that makes you nervous, type open .如果这让您感到紧张,请输入open . instead.反而。 That will open your "home" ( ~ ) directory in Finder, and you can delete node_modules in the familiar, right-click, send-to-trash way there.这将在 Finder 中打开您的“主”( ~ ) 目录,您可以在那里以熟悉的、右键单击、发送到垃圾箱的方式删除node_modules

Hope that helps!希望有帮助!

Delete package-lock.json (not package.json !) and/or yarn.lock in your project folder.删除项目文件夹中的package-lock.json (不是package.json !)和/或yarn.lock

Delete node_modules in your project folder.删除项目文件夹中的node_modules

Remove webpack from dependencies and/or devDependencies in the package.json file in your project folder.从项目文件夹中package.json文件中的依赖项和/或 devDependencies 中删除webpack

Run npm install or yarn , depending on the package manager you use.运行npm installyarn ,具体取决于您使用的包管理器。

I tried all of the above and it was not working but once i added a .env file to my project structure and added SKIP_PREFLIGHT_CHECK=true into the file.我尝试了上述所有方法,但它不起作用,但是一旦我将 .env 文件添加到我的项目结构中并将SKIP_PREFLIGHT_CHECK=true添加到文件中。 i could bypass the problem:我可以绕过这个问题:

问题解决了

This what you put inside the .env file:这是您放入.env文件中的内容:

这是您放入 .env 文件中的内容

you need to try first, make a file with the name .env and store the SKIP_PREFLIGHT_CHECK=true您需要先尝试,创建一个名为.env的文件并存储SKIP_PREFLIGHT_CHECK=true

root/.env and .env should contain SKIP_PREFLIGHT_CHECK=true root/.env.env应该包含SKIP_PREFLIGHT_CHECK=true

  1. create a .env file or edit exiting one.创建一个.env文件或编辑现有文件。
  2. SKIP_PREFLIGHT_CHECK = true write this to .env file. SKIP_PREFLIGHT_CHECK = true将此写入.env文件。
  3. restart dev server.重启开发服务器。

I solved the problem this way.我以这种方式解决了这个问题。

The issue is the webpack installed in your user directory.问题是安装在您的用户目录中的 webpack。 Remove it with npm or by hand and all should run fine: ref: https://github.com/facebook/create-react-app/issues/6120使用 npm 或手动删除它,一切都应该运行良好:参考: https ://github.com/facebook/create-react-app/issues/6120

You can follow the instructions given in the error log.您可以按照错误日志中的说明进行操作。

  1. Delete package-lock.json (not package.json !) and/or yarn.lock in your project folder.删除项目文件夹中的package-lock.json (不是package.json !)和/或yarn.lock

  2. Delete node_modules in your project folder.删除项目文件夹中的node_modules

  3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.从项目文件夹中package.json文件中的依赖项和/或 devDependencies 中删除“webpack”。

  4. Run npm install or yarn , depending on the package manager you use.运行npm installyarn ,具体取决于您使用的包管理器。

  • add "webpack": "4.44.2" to dependencies of package.json .将 "webpack": "4.44.2" 添加到package.json的依赖项中。
  • create .env and type SKIP_PREFLIGHT_CHECK=true That will be solved your problem.创建.env并输入SKIP_PREFLIGHT_CHECK=true这将解决您的问题。

In my case, I removed node_modules from my user's directory.就我而言,我从用户目录中删除了 node_modules 。 It worked.有效。

The solution that worked for me对我有用的解决方案

Add SKIP_PREFLIGHT_CHECK=true to a .env file in your project.SKIP_PREFLIGHT_CHECK=true添加到项目中的 .env 文件中。 I don't know if this may result in errors in the future.我不知道这是否会导致将来出现错误。

从您的用户目录中删除 node_modules,即 C:\Users\User

I've been stuck on this for over an hour.我已经坚持了一个多小时。 I followed every step listed.我遵循列出的每一步。 I deleted node_modules from my project and ALL node modules folders found on my mac.我从我的项目中删除了 node_modules,并在我的 mac 上找到了所有节点模块文件夹。 Then I deleted packagelock and then ran npm install which gave me a fresh nm and packagelock.然后我删除了 packagelock,然后运行npm install ,它给了我一个新的 nm 和 packagelock。

Running npm start keeps giving me the same error.运行npm start不断给我同样的错误。 I know it's not my code because I can checkout another branch and I get the same error.我知道这不是我的代码,因为我可以签出另一个分支并且我得到了同样的错误。

This all started when I installed react testing library and upgraded react-scripts from 2.1.1 to 4. .这一切都是从我安装反应测试库并将反应脚本从 2.1.1 升级到 4 开始的 I upgraded due to an error after running a test that said something about react-scripts (I can't remember what it said exactly.)我在运行一个关于 react-scripts 的测试后由于错误而升级(我不记得它到底说了什么。)

I have since reset my package.json to the old working version with the old react-scripts version and without the testing libraries, followed all the above steps again, and still have the error.我已经将我的 package.json 重置为具有旧 react-scripts 版本且没有测试库的旧工作版本,再次执行上述所有步骤,但仍然有错误。

I don't have webpack in dependencies or dev dependencies.我在依赖项或开发依赖项中没有 webpack。

Here is my previously working package.json这是我以前工作的 package.json

{
    "name": "bidrlfront",
    "version": "1.0.0",
    "private": true,
    "homepage": "./",
    "dependencies": {
      "@date-io/moment": "^1.3.13",
      "@material-ui/core": "^4.12.3",
      "@material-ui/icons": "^4.11.2",
      "@material-ui/pickers": "^3.3.10",
      "camelize": "^1.0.0",
      "chart.js": "^2.7.3",
      "classnames": "^2.2.6",
      "cross-env": "^5.2.0",
      "css-loader": "^1.0.0",
      "dateformat": "^3.0.3",
      "flux": "^3.1.3",
      "lodash.find": "^4.6.0",
      "moment": "^2.29.1",
      "node-sass": "^4.14.1",
      "react": "^16.14.0",
      "react-bootstrap": "^1.6.1",
      "react-dom": "^16.6.3",
      "react-ga": "^2.5.6",
      "react-loading": "^2.0.3",
      "react-quill": "^1.3.3",
      "react-router": "^4.3.1",
      "react-router-dom": "^5.2.0",
      "react-scripts": "2.1.1",
      "shards-react": "^1.0.0",
      "shortid": "^2.2.14"
    },
    "scripts": {
      "start": "react-scripts start",
      "build:prod": "cross-env REACT_APP_BASENAME=/demo/shards-dashboard-lite-react REACT_APP_GAID=UA-115105611-1 npm run build",
      "build": "cross-env REACT_APP_BASENAME=/demo/shards-dashboard-lite-react react-scripts build",
      "test": "react-scripts test",
      "scss": "node-sass --watch -include-path src/css -o css",
      "eject": "react-scripts eject",
      "gitty": "node g.js"
    },
    "eslintConfig": {
      "extends": "react-app"
    },
    "browserslist": [
      ">0.2%",
      "not dead",
      "not ie <= 11",
      "not op_mini all"
    ],
    "devDependencies": {
      "sass-loader": "^7.1.0"
    },
    "repository": {
      "type": "git",
      "url": "git+ssh://git@bitbucket.org/rldev2/bidrl-app.git"
    },
    "keywords": [],
    "author": "Stephanie Raymos <sraymos@rlliquidators.com>",
    "license": "ISC"
  }

And here is my package.json when the errors started occuring当错误开始发生时,这是我的 package.json

{
    "name": "bidrlfront",
    "version": "1.0.0",
    "private": true,
    "homepage": "./",
    "dependencies": {
        "@date-io/moment": "^1.3.13",
        "@material-ui/core": "^4.12.3",
        "@material-ui/icons": "^4.11.2",
        "@material-ui/pickers": "^3.3.10",
        "@testing-library/jest-dom": "^5.14.1",
        "@testing-library/react": "^12.0.0",
        "@testing-library/user-event": "^13.2.1",
        "camelize": "^1.0.0",
        "chart.js": "^2.7.3",
        "classnames": "^2.2.6",
        "cross-env": "^5.2.0",
        "css-loader": "^1.0.0",
        "dateformat": "^3.0.3",
        "flux": "^3.1.3",
        "lodash.find": "^4.6.0",
        "moment": "^2.29.1",
        "node-sass": "^4.14.1",
        "react": "^16.14.0",
        "react-bootstrap": "^1.6.1",
        "react-dom": "^16.6.3",
        "react-ga": "^2.5.6",
        "react-loading": "^2.0.3",
        "react-quill": "^1.3.3",
        "react-router": "^4.3.1",
        "react-router-dom": "^5.2.0",
        "react-scripts": "^2.1.1",
        "shards-react": "^1.0.0",
        "shortid": "^2.2.14"
    },
    "scripts": {
        "start": "react-scripts start",
        "build:prod": "cross-env REACT_APP_BASENAME=/demo/shards-dashboard-lite-react REACT_APP_GAID=UA-115105611-1 npm run build",
        "build": "cross-env REACT_APP_BASENAME=/demo/shards-dashboard-lite-react react-scripts build",
        "test": "react-scripts test",
        "scss": "node-sass --watch -include-path src/css -o css",
        "eject": "react-scripts eject",
        "gitty": "node g.js"
    },
    "eslintConfig": {
        "extends": "react-app"
    },
    "browserslist": [
        ">0.2%",
        "not dead",
        "not ie <= 11",
        "not op_mini all"
    ],
    "devDependencies": {
        "sass-loader": "^7.1.0"
    },
    "repository": {
        "type": "git",
        "url": "git+ssh://git@bitbucket.org/rldev2/bidrl-app.git"
    },
    "keywords": [],
    "author": "Stephanie Raymos <sraymos@rlliquidators.com>",
    "license": "ISC"
}

I had also globally installed testing library and fsevents prior to the error occuring but uninstalled those and trashed the folders on my mac.在发生错误之前,我还全局安装了测试库和 fsevents,但卸载了这些并删除了我的 mac 上的文件夹。

I installed fsevents after receiving this error when I attempted to run my app after installing the testing libraries: Error: fsevents unavailable (this watcher can only be used on Darwin)我在安装测试库后尝试运行我的应用程序时收到此错误后安装了 fsevents:错误: fsevents不可用(此观察程序只能在 Darwin 上使用)

I was getting a blank screen.我得到一个空白屏幕。 This solved that issue.这解决了这个问题。 I then got an error logging with my auth system.然后我的身份验证系统出现错误记录。 I was using rxjs.我正在使用 rxjs。 I had to install that.我不得不安装它。 Got a react-scripts error and updated that to the latest version.收到 react-scripts 错误并将其更新到最新版本。 That's when everything broke.就在那时,一切都破裂了。 When I run npm ls webpack I get this:当我运行npm ls webpack ,我得到了这个:

├─┬ css-loader@1.0.1
│ └─┬ webpack@4.46.0
│   └─┬ terser-webpack-plugin@1.4.5
│     └── webpack@4.46.0 deduped
├─┬ react-scripts@2.1.1
│ ├─┬ babel-loader@8.0.4
│ │ └── webpack@4.46.0 deduped
│ ├─┬ css-loader@1.0.0
│ │ └── webpack@4.19.1 deduped
│ ├─┬ eslint-loader@2.1.1
│ │ └── webpack@4.46.0 deduped
│ ├─┬ file-loader@2.0.0
│ │ └── webpack@4.46.0 deduped
│ ├─┬ fork-ts-checker-webpack-plugin-alt@0.4.14
│ │ └── webpack@4.46.0 deduped
│ ├─┬ html-webpack-plugin@4.0.0-alpha.2
│ │ └── webpack@4.46.0 deduped
│ ├─┬ mini-css-extract-plugin@0.4.3
│ │ └── webpack@4.46.0 deduped
│ ├─┬ optimize-css-assets-webpack-plugin@5.0.1
│ │ └── webpack@4.46.0 deduped
│ ├─┬ sass-loader@7.1.0
│ │ └── webpack@4.19.1 deduped
│ ├─┬ terser-webpack-plugin@1.1.0
│ │ └── webpack@4.46.0 deduped
│ ├─┬ url-loader@1.1.1
│ │ └── webpack@4.46.0 deduped
│ ├─┬ webpack-dev-server@3.1.9
│ │ ├─┬ webpack-dev-middleware@3.4.0
│ │ │ └── webpack@4.46.0 deduped
│ │ └── webpack@4.46.0 deduped
│ ├─┬ webpack-manifest-plugin@2.0.4
│ │ └── webpack@4.46.0 deduped
│ ├─┬ webpack@4.19.1
│ │ └─┬ uglifyjs-webpack-plugin@1.3.0
│ │   └── webpack@4.46.0 deduped
│ └─┬ workbox-webpack-plugin@3.6.3
│   └── webpack@4.46.0 deduped
└─┬ sass-loader@7.3.1
  └── webpack@4.46.0 deduped

当您制作所有项目时,问题在于您计算机上的树文件夹,请尝试文件夹中不存在的应用程序,我希望它会起作用

Do as it's saying on the error to make it work.按照错误的说法去做以使其工作。
Create a .env file in your project directory and add SKIP_PREFLIGHT_CHECK=true , it will work.在您的项目目录中创建一个.env文件并添加SKIP_PREFLIGHT_CHECK=true ,它将起作用。

I have faced the same problem before and I solved it.我以前也遇到过同样的问题,我解决了。 The create-react-app already provided webpack(v4.29.6) , which conflicts with webpack(v4.33.0) in /Users/aliceparker/node_modules . create-react-app已经提供了webpack(v4.29.6) ,它与/Users/aliceparker/node_modules中的webpack(v4.33.0)冲突。

So if you remove the second webpack(v4.33.0) , it would run.因此,如果您删除第二个webpack(v4.33.0) ,它将运行。

I created project using npx and I was getting same error with babel-eslint initially.我使用 npx 创建了项目,最初使用 babel-eslint 时遇到了同样的错误。 I followed @davidflyod91 approach, it worked for me.我遵循@davidflyod91 方法,它对我有用。 Im not happy with deleting the whole node_module folder from ~ directory (in my MAC)(i mean to say the place where -g modules are installed).我不满意从 ~ 目录(在我的 MAC 中)删除整个 node_module 文件夹(我的意思是说安装 -g 模块的位置)。 So, I put back the node_modules and deleted folders associate with below ones from node_modules in ~/node_modules directory and tried running the application (npm run start).因此,我从 ~/node_modules 目录中的 node_modules 中放回了 node_modules 和已删除的文件夹,并尝试运行应用程序(npm run start)。

  • Webpack网页包
  • babel通天塔
  • eslint埃斯林特
  • create-react-app创建反应应用

And then application started working.然后应用程序开始工作。

Add the line "webpack": "4.44.2" to the dependencies of your package.json file."webpack": "4.44.2"行添加到package.json文件的依赖项中。 Create the .env file, and type SKIP_PREFLIGHT_CHECK=true inside, which will solve your problem.创建.env文件,然后在里面输入SKIP_PREFLIGHT_CHECK=true ,这将解决您的问题。

You can simply delete the node_module folder.您可以简单地删除node_module文件夹。 it will work.它会起作用的。 Go to the root and then run the following command Go 到根目录然后运行以下命令

sudo rm -rf /Users/yourname/node_modules

The simple solution is just to install the webpack version shown in error.简单的解决方案就是安装错误显示的 webpack 版本。

npm install webpack@version show in error. npm 安装 webpack@version 显示错误。

I hope this will help you.我希望这能帮到您。 Thank you very much.非常感谢。

I had the same error and none of the solutions helped me fully.我有同样的错误,没有一个解决方案能完全帮助我。 Then I actually followed the instructions on the error and the issue was resolved然后我实际上按照错误的说明进行操作并解决了问题

  1. Deleted package-lock.json删除包锁.json
  2. Delete node_modules in the project folder.删除项目文件夹中的 node_modules。
  3. Make sure to run npm install.确保运行 npm 安装。 If you dont and go straight to npm start you will have a "react-scripts: command not found error"如果你不和 go 直接到 npm 启动你将有一个“react-scripts: command not found error”

Edit:Issue reoccured and was resolved by adding the.env file to the root of my project and added SKIP_PREFLIGHT_CHECK=true into the file.编辑:问题再次发生并通过将 .env 文件添加到我的项目的根目录并将 SKIP_PREFLIGHT_CHECK=true 添加到文件中得到解决。

Issue was fully resolved now.问题现已完全解决。

  • First try npm install , then npm start首先尝试npm install ,然后npm start
  • If it doesn't work then run npm audit如果它不起作用,则运行npm audit
  • Then try npm audit fix or npm audit fix --force , then npm install , then npm start然后尝试npm audit fixnpm audit fix --force ,然后npm install ,然后npm start
  • If it still doesn't work, delete node modules , package-lock.json and again try npm install , then npm start如果还是不行,删除node modules , package-lock.json然后再试试npm install , 然后npm start

Still getting error?仍然出现错误? Set SKIP_PREFLIGHT_CHECK=true inside of .env file.env文件中设置SKIP_PREFLIGHT_CHECK=true

And try again .再试一次

To fix the dependency tree, try following the steps below in the exact order:要修复依赖关系树,请尝试按确切顺序执行以下步骤:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.删除项目文件夹中的 package-lock.json(不是 package.json!)和/或 yarn.lock。
  2. Delete node_modules in your project folder.删除项目文件夹中的 node_modules。
  3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.从项目文件夹中 package.json 文件中的依赖项和/或 devDependencies 中删除“webpack”。
  4. Run npm install or yarn, depending on the package manager you use.运行 npm install 或 yarn,取决于你使用的包管理器。

In most cases, this should be enough to fix the problem.在大多数情况下,这应该足以解决问题。 If this has not helped, there are a few other things you can try:如果这没有帮助,您可以尝试其他一些方法:

  1. If you used npm, install yarn ( http://yarnpkg.com/ ) and repeat the above steps with it instead.如果您使用 npm,请安装 yarn ( http://yarnpkg.com/ ) 并用它重复上述步骤。 This may help because npm has known issues with package hoisting which may get resolved in future versions.这可能会有所帮助,因为 npm 已经知道包提升的问题,这些问题可能会在未来的版本中得到解决。

  2. Check if /home/omage/node_modules/webpack is outside your project directory.检查 /home/omage/node_modules/webpack 是否在您的项目目录之外。 For example, you might have accidentally installed something in your home folder.例如,您可能不小心在主文件夹中安装了一些东西。

  3. Try running npm ls webpack in your project folder.尝试在您的项目文件夹中运行 npm ls webpack。 This will tell you which other package (apart from the expected react-scripts) installed webpack.这将告诉你哪个其他包(除了预期的 react-scripts)安装了 webpack。

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.如果没有其他帮助,请将 SKIP_PREFLIGHT_CHECK=true 添加到项目中的 .env 文件中。 That would permanently disable this preflight check in case you want to proceed anyway.如果您仍然想继续,这将永久禁用此预检检查。

Answer To fix the dependency tree回答 修复依赖树

to solve a dependency tree problem, you have to delete the node-modules file from your local computer and run npm start , to start the localhost要解决依赖树问题,您必须从本地计算机中删除 node-modules 文件并运行 npm start 以启动 localhost

create an .env file and put this line "SKIP_PREFLIGHT_CHECK=true"创建一个 .env 文件并将这一行放入“SKIP_PREFLIGHT_CHECK=true”

example例子

I created .env file and i added SKIP_PREFLIGHT_CHECK=true in it.我创建了 .env 文件,并在其中添加了 SKIP_PREFLIGHT_CHECK=true 。

Note: don't give any name to .env file, created filname must be .env注意:不要给 .env 文件起任何名字,创建的文件名必须是 .env

picture for more understanding图片便于理解

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM