Shiglet
Shiglet

Reputation: 111

different versions of webpack are needed, npm start throws an error

I have created years ago a react project using create-react-app. In my react project i have a dependency to the [email protected] npm package. But i also have a dependency to a npm package that needs [email protected] package (so different versions). When running npm install, i don't have any issue. But when running the command npm start, i have this error prompted :

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

  "webpack": "4.42.0"

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:

  D:\Dev\Foo\node_modules\webpack (version: 4.44.2)

So from what i understood, the [email protected] that i have in my package.json needs [email protected], while another package need the [email protected] version (which is the installed one by npm). I checked with the command npm ls webpack to see what versions of webpack are needed in the tree. And it confirms that.

My knowledges about npm is not that good. I thought it could be "smart" enough to install multiple version of the same package, but it seems to not be the case.

What can i do to fix that please ?

Also explanations are really appreciated. Knowing how a tool, that i'm using every day, works is a good thing.

Upvotes: 1

Views: 785

Answers (1)

اوسكو
اوسكو

Reputation: 27

create .env file in your root directory and add this line that file

SKIP_PREFLIGHT_CHECK=true

this will solve your problem.

Upvotes: 1

Related Questions