Unable to resolve dependency tree, webpack and xxx-loader version incompatibility problem solving (detailed steps)

Unable to resolve dependency tree, webpack and xxx-loader version incompatibility problem solving (detailed steps)

01. Question

1. An error occurs when npm install style-loader, as shown in the figure below

wrong picture

2. There is still no way to solve the version specified in the installation diagram

02. Problem analysis

1. It can be seen that this is an error caused by the incompatibility between webpack and style-loader version
2. Just install the corresponding version
3. So how do you know which version to install?

03. Problem Solving

1. At this time, we need to check the version number of webpack installed in the current project, click on the package.json file, and you can check the version number of webpack under the "dependencies" option, as shown in the figure below

webpack version number

2. Go to webpack GitHub ( webpack GitHub official link ) to find the corresponding version number (take this article webpack: ^4.46.0) as an example, it belongs to the version of webpack-4 on GitHub, select the corresponding branch, as shown in the figure below

webpack version

3. After switching to the corresponding branch, find the package.json file and view the file, as shown in the figure below

The package.json of the corresponding version

4. In the "devDependencies" option, find the dependency that the installation reports an error (the dependency installed in this article is: style-loader), as shown in the figure below

Corresponding dependencies
Then you can find the compatible version of the dependencies of the current webpack (version 4.46.0) ("style-loader": "^0.23.1")

5. Install a compatible version (npm install style-loader@^0.23.1), as shown in the figure below

successfully installed

hint

This kind of error message appears, most of which are webpack and xxx-loader versions are not compatible, go to the official to find the corresponding dependencies and reinstall them to solve the problem

Guess you like

Origin blog.csdn.net/mrliucx/article/details/129671857