module-federation / module-federation-examples

Implementation examples of module federation , by the creators of module federation
https://module-federation.io/
MIT License
5.66k stars 1.75k forks source link

Error: Cannot find module 'D:\NEXTJS\sample-next-micro\node_modules\next\dist\compiled\lib\ModuleNotFoundError' #4301

Closed apipkurniawan closed 3 weeks ago

apipkurniawan commented 3 weeks ago

when npm run dev, i get this error

Error: Cannot find module 'D:\NEXTJS\sample-next-micro\node_modules\next\dist\compiled\lib\ModuleNotFoundError'

how to fix it?

my package.json

...
"dependencies": {
    "@module-federation/nextjs-mf": "^8.6.3",
    "next": "^14.2.13",
    "react": "^18",
    "react-dom": "^18",
    "webpack": "^5.95.0"
  },
...

my next.config.js

// eslint-disable-next-line @typescript-eslint/no-require-imports
const NextFederationPlugin = require("@module-federation/nextjs-mf");

module.exports = {
  webpack(config, options) {
    if (!options.isServer) {
      config.plugins.push(
        new NextFederationPlugin({
          name: "home",
          remotes: {},
          filename: "static/chunks/remoteEntry.js",
          exposes: {
            "./home": "./src/pages/index.tsx",
          },
          shared: {},
          extraOptions: {},
        })
      );
    }

    return config;
  },
};
ScriptedAlchemy commented 3 weeks ago

Read the docs