Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextjs-mf@8.5.0 with Next 14: Module not found #2946

Open
5 tasks done
rehmanjaved1 opened this issue Sep 11, 2024 · 4 comments
Open
5 tasks done

nextjs-mf@8.5.0 with Next 14: Module not found #2946

rehmanjaved1 opened this issue Sep 11, 2024 · 4 comments

Comments

@rehmanjaved1
Copy link

Describe the bug

I'm using Ubuntu and have just set up a new project. After installing the Module Federation package and completing all the necessary configurations, I encountered the following error when attempting to run the project:

image

Reproduction

just setup a new next js 14 project and install module federation package

Used Package Manager

npm

System Info

System:
    OS: Linux 6.8 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
    Memory: 4.66 GB / 15.49 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v18.13.0/bin/yarn
    npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm
    pnpm: 9.10.0 - ~/.nvm/versions/node/v18.13.0/bin/pnpm
  Browsers:
    Chrome: 125.0.6422.141

Validations

@rehmanjaved1 rehmanjaved1 changed the title Module not found nextjs-mf@8.5.0 with Next 14: Module not found Sep 11, 2024
@AndersonHqds
Copy link

AndersonHqds commented Sep 11, 2024

The same here and i'm using next 12, it looks like all the imports that is using the normalize-webpack-path module is breaking. I'm getting the error bellow, but when i change the import for example in the resolveMatchedConfigs.js
from :
const ModuleNotFoundError = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/ModuleNotFoundError'));
to:
const ModuleNotFoundError = require('webpack/lib/ModuleNotFoundError');
it stops the error


   Require stack:
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/lib/sharing/resolveMatchedConfigs.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/lib/sharing/ConsumeSharedPlugin.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/lib/sharing/SharePlugin.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/lib/container/ModuleFederationPlugin.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/wrapper/ModuleFederationPlugin.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/index.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/plugins/container/InvertedContainerRuntimeModule.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/plugins/container/EmbeddedContainerPlugin.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/plugins/container/InvertedContainerPlugin.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/plugins/NextFederationPlugin/index.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/index.js
   - /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/apps/peers/authentication/next.config.js

Error: Cannot find module '/Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/next/dist/compiled/lib/ModuleNotFoundError'
Require stack:
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/lib/sharing/resolveMatchedConfigs.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/lib/sharing/ConsumeSharedPlugin.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/lib/sharing/SharePlugin.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/lib/container/ModuleFederationPlugin.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/wrapper/ModuleFederationPlugin.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/index.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/plugins/container/InvertedContainerRuntimeModule.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/plugins/container/EmbeddedContainerPlugin.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/plugins/container/InvertedContainerPlugin.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/plugins/NextFederationPlugin/index.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/nextjs-mf/dist/src/index.js
- /Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/apps/peers/authentication/next.config.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at mod._resolveFilename (/Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/next/dist/build/webpack/require-hook.js:183:28)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/Users/anderson.henrique/Desktop/dev/anderson/platform/benf-companies-app-platform/node_modules/@module-federation/enhanced/dist/src/lib/sharing/resolveMatchedConfigs.js:9:29)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)```

@robcaldecott
Copy link

robcaldecott commented Sep 18, 2024

Same here although npm run build seems to work. It's npm run dev giving me this error. Not sure if that helps anyone!

@EnochGao
Copy link
Contributor

#2944 same issue, build has same error

@ScriptedAlchemy
Copy link
Member

Npm install webpack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants