2

I am trying to develop microfrontends in NextJs 10 project as described by https://gist.github.com/jherr/dd10bc34448590a2661a0c6acbcc7e8a/revisions. But when I try to run it, both in my project and in the one with the example https://github.com/jherr/wp5-nextjs-10.git I get the following error: Error: Module Federation only works with Webpack 5

Error: Module Federation only works with Webpack 5

I am using Windows 10 and my Node version is v14.12.0

How can I fix this?

Yoe
  • 23
  • 5
  • You could try enabling webpack 5 in Next.js. Check [how to use webpack 5 configs in nextjs?](https://stackoverflow.com/a/66125274/1870780) for details. – juliomalves Mar 10 '21 at 12:12
  • @juliomalves already today I fixed it, updated my global webpack and reinstalled all the project packages again. Apparently the version of webpack that was being installed was that of my global environment which was below version 5. Thank you very much! – Yoe Mar 10 '21 at 18:32
  • 1
    @juliomalves Anyway I update, you are absolutely right, in addition to updating my global webpack it is strictly necessary to do what they indicate and the answer that you shared with me. Thanks so much !! Solution -> https://stackoverflow.com/a/66125274/1870780 – Yoe Mar 22 '21 at 04:25

1 Answers1

0

Module federation is a new feature of webpack 5. The error message has to be taken quite literally. You have to upgrade your webpack over your package manager (like yarn or npm) to use it. To help with that, webpack offers migration articles that explain what has to be changed when upgrading (e.g. v3-v4 and v4-v5). You probably have webpack globally installed and the version is too old.

Mirco S.
  • 2,510
  • 4
  • 13
  • 1
    Thank you very much, I really fixed it with the update of my gloal webpack and the solution that @juliomalves shared with me. – Yoe Mar 22 '21 at 04:27