Regarding this error, I have tried various solutions on the Internet before. After testing, I downgraded the original @vue/cli version to version 4.5.15 and finally reinstalled the node_modules package.
Below I will introduce how to install the 4.5.15 version of scaffolding, etc.
(1) First, you need to uninstall the globally installed @vue/cli (I installed version 5.0.8 before)
npm uninstall -g @vue/cli
/*
当然,你也可以先执行
yarn cache clean --force
清除一下缓存,都没问题
*/
(2) Check whether the @vue/cli scaffolding has been completely uninstalled (if the original version of the scaffolding is not completely uninstalled, it will conflict with the 4.5.15 version installed later)
vue --version
From the prompt, we can find that our @vue/cli is still there and has not been deleted. The reason is that the data of the previously installed scaffolding has not been completely deleted, this is very critical.
Next we execute where vue to view the data location of @vue/cli installed before
(3) Execute where vue to view the location of the current @vue/cli installed data
where vue
You can find that there are two files, vue and vue.cmd. These two files are in the c drive. Then we copy this path to the c drive and delete these two files.
Of course, it is also possible that these two files are not on the c drive. For the same reason, just go to the where vue path and delete them.
(4) Then execute vue --version again to check whether the scaffolding still exists (here I am using cmd to check, it can also be checked in git, but the prompt may be different from cmd. To demonstrate the effect, I choose to use cmd )
vue --version
As you can see, the scaffolding no longer exists, which means it has been deleted.
(5) Start installing scaffolding
npm install -g @vue/[email protected]
After the installation is complete, you can first check whether the installation is successful and execute vue --version
(6) Manually delete the dependent package node_modules of the original project, and then reinstall the dependent package and execute
(这步也很关键)
npm install
Finally, after re-running, I found that it could run successfully. . . . Tears, tears, although version 4.5.15 was installed before, this error was still reported when running because the dependent packages were not reinstalled~~.
(7) Summary
To sum up, regarding the reason for this error "Error: Cannot find module 'webpack/lib/RuleSet", it may be that there is an individual mismatch between the current scaffolding version and the packages that the current project depends on, causing the scaffolding to fail when running the project. The relevant packages were missing, and my previous scaffolding version was the latest version, so I needed to downgrade the scaffolding version and try it, and it worked. Of course, just a personal opinion.
If you have other solutions, brothers are welcome to communicate~~~~