Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

reactjs - Why React npm start return error for webpack-dev-server 3.11.1?

I have the following error with npm start in my React application:

The react-scripts package provided by Create React App requires a dependency:

  "webpack-dev-server": "3.11.1"

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:UsersUsername
ode_moduleswebpack-dev-server (version: 3.11.0)

Usually I fixed this type of issue by running the following code: npm install react-scripts@latest.

But now it seems like that React is not updated yet to the latest webpack-dev-server

Now the question is how to fix that. By the way, I use npx create-react-app for my project, Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

First, remove the node_modules folder and yarn-lock or package-lock.json file.

And, then add this line in your .env file:

SKIP_PREFLIGHT_CHECK=true

Now you can do npm start or yarn start after re-installing the packages. It should work.

Explanation:

For some reasons, you have two versions of webpack-dev-server installed in your project's node_modules. By setting SKIP_PREFLIGHT_CHECK=true in .env file, we are telling npm to ignore such version issues.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...