简体   繁体   中英

Problem with installing react dependencies

I am trying to install react using this command: npx create-react-app.

Then I tried to run using this command: 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:

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

Try to create a .env file in the root directory of the project and add this line SKIP_PREFLIGHT_CHECK=true inside the file.

then try to run yarn start or npm start .

Did you give a project name after 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:

  1. Follow steps 1-4 that are initially provided in project directory and commit updated changes locally~

i. Delete package-lock.json (not package.json.) and/or yarn.lock in your project folder.

ii. Delete node_modules in your project folder.

iii. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.

iv. Run npm install or yarn, depending on the package manager you use.

  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)

  2. Go there and delete it

  3. once done try npm start

should work:)!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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