简体   繁体   English

安装反应依赖项的问题

[英]Problem with installing react dependencies

I am trying to install react using this command: npx create-react-app.我正在尝试使用以下命令安装反应: npx create-react-app.

Then I tried to run using this command: npm run start然后我尝试使用这个命令运行: npm run start

Then I get this error:然后我得到这个错误:

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-dev-server": "3.10.3"

Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack-dev-server was detected higher up in the tree:

  C:\Users\oa\Desktop\node_modules\webpack-dev-server (version: 3.11.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.
That will permanently disable this message but you might encounter other issues.

As suggested here [https://stackoverflow.com/questions/42308879/npm-err-code-elifecycle][1], I have tried to fix it using the following commands:正如这里所建议的 [https://stackoverflow.com/questions/42308879/npm-err-code-elifecycle][1],我尝试使用以下命令修复它:

delete package-lock.json
npm cache clean --force
npm install
npm start 

But did not fixed for me.但没有为我修好。

Just to let you know, my npm version is 6.13.6 , and node version is v13.8.0只是告诉你,我的 npm 版本是6.13.6 ,节点版本是v13.8.0

Try to create a .env file in the root directory of the project and add this line SKIP_PREFLIGHT_CHECK=true inside the file.尝试在项目的根目录中创建一个.env文件,并在文件中添加这一行SKIP_PREFLIGHT_CHECK=true

then try to run yarn start or npm start .然后尝试运行yarn startnpm start

Did you give a project name after npx create-react-app 'appName' ?你在npx create-react-app 'appName'之后给了项目名称吗?

If you have multiple node_modules folders with different versions of dependencies one may conflict with the other - do the following:如果您有多个具有不同版本依赖项的 node_modules 文件夹,其中一个可能会与另一个冲突 - 执行以下操作:

  1. Follow steps 1-4 that are initially provided in project directory and commit updated changes locally~按照最初在项目目录中提供的步骤 1-4 并在本地提交更新的更改~

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

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

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

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

  1. Find the location of the node_modules folder that is not in your project folder ~ this line - (C:\Users\oa\Desktop\node_modules\webpack-dev-server)找到不在您的项目文件夹中的node_modules文件夹的位置~这一行 - (C:\Users\oa\Desktop\node_modules\webpack-dev-server)

  2. Go there and delete it Go 在那里并删除它

  3. once done try npm start完成后尝试npm start

should work:)!应该管用:)!

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

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