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

Cannot find module clients\node_modules\next\dist\compiled\lib\util\makeSerializable #2048

Closed
5 tasks done
pabloLarios24 opened this issue Jan 29, 2024 · 16 comments
Closed
5 tasks done
Assignees
Labels
nextjs-mf nextjs-mf package identifier

Comments

@pabloLarios24
Copy link

Describe the bug

When run the command "next dev", I got this error:

Error: Cannot find module 'C:\Users\user\Desktop\proyects\clients\node_modules\next\dist\compiled\lib\util\makeSerializable'
Require stack:

  • C:\Users\user\Desktop\proyects\clients\node_modules@module-federation\enhanced\dist\src\lib\container\ContainerExposedDependency.js
  • C:\Users\user\Desktop\proyects\clients\node_modules@module-federation\enhanced\dist\src\lib\container\ContainerEntryModule.js
  • C:\Users\user\Desktop\proyects\clients\node_modules@module-federation\enhanced\dist\src\lib\container\HoistContainerReferencesPlugin.js
  • C:\Users\user\Desktop\proyects\clients\node_modules@module-federation\enhanced\dist\src\wrapper\HoistContainerReferencesPlugin.js
  • C:\Users\user\Desktop\proyects\clients\node_modules@module-federation\enhanced\dist\src\index.js
  • C:\Users\user\Desktop\proyects\clients\node_modules@module-federation\nextjs-mf\dist\src\internal.js
  • C:\Users\user\Desktop\proyects\clients\node_modules@module-federation\nextjs-mf\dist\src\plugins\NextFederationPlugin\next-fragments.js
  • C:\Users\user\Desktop\proyects\clients\node_modules@module-federation\nextjs-mf\dist\src\plugins\NextFederationPlugin\index.js
  • C:\Users\user\Desktop\proyects\clients\node_modules@module-federation\nextjs-mf\dist\src\index.js
  • C:\Users\user\Desktop\proyects\clients\next.config.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at C:\Users\user\Desktop\proyects\clients\node_modules\next\dist\server\require-hook.js:55:36
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at mod.require (C:\Users\user\Desktop\proyects\clients\node_modules\next\dist\server\require-hook.js:65:28)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object. (C:\Users\user\Desktop\proyects\clients\node_modules@module-federation\enhanced\dist\src\lib\container\ContainerExposedDependency.js:8:26)
    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) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    'C:\Users\user\Desktop\proyects\clients\node_modules\@module-federation\enhanced\dist\src\lib\container\ContainerExposedDependency.js',
    'C:\Users\user\Desktop\proyects\clients\node_modules\@module-federation\enhanced\dist\src\lib\container\ContainerEntryModule.js',
    'C:\Users\user\Desktop\proyects\clients\node_modules\@module-federation\enhanced\dist\src\lib\container\HoistContainerReferencesPlugin.js',
    'C:\Users\user\Desktop\proyects\clients\node_modules\@module-federation\enhanced\dist\src\wrapper\HoistContainerReferencesPlugin.js',
    'C:\Users\user\Desktop\proyects\clients\node_modules\@module-federation\enhanced\dist\src\index.js',
    'C:\Users\user\Desktop\proyects\clients\node_modules\@module-federation\nextjs-mf\dist\src\internal.js',
    'C:\Users\user\Desktop\proyects\clients\node_modules\@module-federation\nextjs-mf\dist\src\plugins\NextFederationPlugin\next-fragments.js',
    'C:\Users\user\Desktop\proyects\clients\node_modules\@module-federation\nextjs-mf\dist\src\plugins\NextFederationPlugin\index.js',
    'C:\Users\user\Desktop\proyects\clients\node_modules\@module-federation\nextjs-mf\dist\src\index.js',
    'C:\Users\user\Desktop\proyects\clients\next.config.js'
    ]
    }

My next.config.js:
const { NextFederationPlugin } = require("@module-federation/nextjs-mf");

module.exports = {
webpack(config, options) {
if (!options.isServer) {
config.plugins.push(
new NextFederationPlugin({
name: "host",
remotes: {
remote: "remote@http://localhost:3001/remote.js",
},
filename: "static/chunks/remoteEntry.js",
})
);
}

return config;

},
};

Reproduction

Run command next dev

Used Package Manager

npm

System Info

"webpack-dev-server": "^4.15.1"
"next": "14.1.0
"react": "^18",
"react-dom": "^18",
"@module-federation/nextjs-mf": "^8.1.7",

Validations

@X3R02
Copy link

X3R02 commented Jan 29, 2024

Same issue

@nyqykk nyqykk added the nextjs-mf nextjs-mf package identifier label Jan 30, 2024
@ScriptedAlchemy
Copy link
Member

#1530

@aminnoura
Copy link

aminnoura commented Feb 21, 2024

same issue.

tried NEXT_PRIVATE_LOCAL_WEBPACK with true but still didn't work

@dilanbopanna
Copy link

Hi @ScriptedAlchemy

Facing the same issue even after adding NEXT_PRIVATE_LOCAL_WEBPACK = 'true'.
Error:
Cannot find module '/Users/xxxx/Code/xxx/node_modules/next/dist/compiled/lib/util/makeSerializable'

@leonardmns12
Copy link

same issue here

@vipulsharma144
Copy link

Anyone found a fix ?

@akshayjai1
Copy link

facing same error

@akshayjai1
Copy link

akshayjai1 commented Mar 6, 2024

try the latest verion of @module-federation/nextjs-mf@8.2.0 it is working for me

https://www.npmjs.com/package/@module-federation/nextjs-mf/v/8.2.0

@vipulsharma144 @leonardmns12 @dilanbopanna @aminnoura @X3R02 @pabloLarios24

I also installed webpack and put NEXT_PRIVATE_LOCAL_WEBPACK in .env.app.local and .env file

@decanTyme
Copy link

decanTyme commented Mar 6, 2024

Can confirm on windows (git bash) it doesn't work (v8.2.0). Since I can't run NEXT_PRIVATE_LOCAL_WEBPACK=true next dev, putting it into an .env* file didn't work either. What worked for me tho was running it in WSL.

What also worked was using the latest canary, which at the time of writing was 8.1.0-canary.7, but had the issue in #1530.

tl;dr the issue for me is that in node_modules/next/dist/compiled/webpack/webpack.js, if the NEXT_PRIVATE_LOCAL_WEBPACK isn't set it goes through the else branch (which I think doesn't have the said module) instead of the other one and everything fails.

@ScriptedAlchemy
Copy link
Member

yarn patch the file if you cant find a way to make next see it. If you have a solution feel free to PR the readme with a note for other windows users

@NeryChi
Copy link

NeryChi commented May 2, 2024

My configurations in package.json

"scripts": {
     "dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next dev",
     "build": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next build",
     "start": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next start",
     "lint": "next lint"
   },

Check out this article: https://rafaelneto.dev/blog/configurar-variables-entorno-package-json-windows/

It worked for me on my windows system.

@MobinKasiri
Copy link

MobinKasiri commented May 28, 2024

same issue

@VuongNQ
Copy link

VuongNQ commented Jun 28, 2024

My configurations in package.json

"scripts": {
     "dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next dev",
     "build": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next build",
     "start": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next start",
     "lint": "next lint"
   },

Check out this article: https://rafaelneto.dev/blog/configurar-variables-entorno-package-json-windows/

It worked for me on my windows system.

I have simple way to run command on window, check it out

 "scripts": {
    "dev": "NEXT_PRIVATE_LOCAL_WEBPACK=true next dev -p 3000",
    "dev-window": "set NEXT_PRIVATE_LOCAL_WEBPACK=true && next dev -p 3000"
  },

@Staslios
Copy link

Staslios commented Aug 9, 2024

Im on windows machine neither .env nor switching powershell/git bash seems to fix the problem, but

     "dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next dev",
    "dev-window": "set NEXT_PRIVATE_LOCAL_WEBPACK=true && next dev -p 3000"

they both do the trick, thanks @VuongNQ

@GuidoGaglia
Copy link

NEXT_PRIVATE_LOCAL_WEBPACK=true next dev -p 3000

work for me. Ubuntu 22.04, only use this line -->
"dev": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next dev"

@ScriptedAlchemy
Copy link
Member

Warning Support for next is ending

#3153

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

No branches or pull requests