vue-loader: Cannot find module 'webpack/lib/RuleSet'
Version
15.4.0
Reproduction link
https://www.npmjs.com/package/vue-loader/v/15.4.2
Steps to reproduce
Init a project without installing webpack locally , and run global webpack in terminal
What is expected?
webpack build successfully
What is actually happening?
Error: Cannot find module ‘webpack/lib/RuleSet’
Due to line 2 in node_modules/vue-loader/lib/plugin.js
const RuleSet = require('webpack/lib/RuleSet')
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 12
- Comments: 17 (2 by maintainers)
Commits related to this issue
- chore: add missing dependencies (#1336) fixes #1427 — committed to xc2/vue-loader by ishitatsuyuki 6 years ago
This happens with the
nextversion of Webpack (Webpack 5.0.0-rc.1)Check this https://github.com/vuejs/vue-loader/issues/1586#issuecomment-528682809 Adding
webpackas a dev dependency resolved the issue for me.FYI, this was the only relevant search result when I also encountered the error you mentioned @hieutranminh in a Nuxt project. So in case anyone else out there is also trying to use Webpack 5 with Nuxt, it’s a matter of @nuxt/components not yet supporting webpack5, and we can move that discussion over there: https://github.com/nuxt/components/issues/105
It has to be webpack ^4.0.0 as the file was removed in v5.
https://github.com/webpack/webpack/commit/74d4669d738a0f4e1587416cbc64839736eff39a#diff-f953e9f47b1aa87d20fc094ba839f3b5c5e145cf963ba0c151185bd3f344cdd3
Both v15 & v16 have already added support for webpack 5. So if you still encounter this issue, please open a new issue with a minimal reproduction.