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

Most upvoted comments

This happens with the next version of Webpack (Webpack 5.0.0-rc.1)

Check this https://github.com/vuejs/vue-loader/issues/1586#issuecomment-528682809 Adding webpack as 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

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.