module-federation-examples icon indicating copy to clipboard operation
module-federation-examples copied to clipboard

NEXT_PRIVATE_LOCAL_WEBPACK

Open parag3638 opened this issue 1 year ago • 3 comments

This is my package.json

{ "name": "remote", "version": "0.1.0", "private": true, "scripts": { "dev": "NEXT_PRIVATE_LOCAL_WEBPACK=true && next dev", "build": "NEXT_PRIVATE_LOCAL_WEBPACK=true && next build", "start": "next start", "lint": "next lint" }, "dependencies": { "@module-federation/nextjs-mf": "^8.1.7", "next": "14.1.0", "react": "^18", "react-dom": "^18" }, "resolutions": { "webpack": "5.1.3" }, "devDependencies": { "eslint": "^8", "eslint-config-next": "14.1.0" } }

I am facing this error

▲ Next.js 14.1.0

  • Local: http://localhost:3000

Error: process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and "npm install webpack" at NextFederationPlugin.validateOptions

parag3638 avatar Feb 02 '24 18:02 parag3638

@parag3638 , Remove the NEXT_PRIVATE_LOCAL_WEBPACK = true from the dev and build scripts in the package.json file. Instead, create a .env file and add the NEXT_PRIVATE_LOCAL_WEBPACK = true

sathishkumar555 avatar Feb 04 '24 18:02 sathishkumar555

@sathishkumar555 It worked but now I am stuck with this....

Error: Cannot find module 'C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\next\dist\compiled\lib\util\makeSerializable' Require stack:

  • C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules@module-federation\enhanced\dist\src\lib\container\ContainerExposedDependency.js
  • C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules@module-federation\enhanced\dist\src\lib\container\ContainerEntryModule.js
  • C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules@module-federation\enhanced\dist\src\lib\container\HoistContainerReferencesPlugin.js
  • C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules@module-federation\enhanced\dist\src\wrapper\HoistContainerReferencesPlugin.js
  • C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules@module-federation\enhanced\dist\src\index.js
  • C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules@module-federation\nextjs-mf\dist\src\internal.js
  • C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules@module-federation\nextjs-mf\dist\src\plugins\NextFederationPlugin\next-fragments.js
  • C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules@module-federation\nextjs-mf\dist\src\plugins\NextFederationPlugin\index.js
  • C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules@module-federation\nextjs-mf\dist\src\index.js
  • C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\next.config.js at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15) at C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\next\dist\server\require-hook.js:55:36 at Module._load (node:internal/modules/cjs/loader:985:27) at Module.require (node:internal/modules/cjs/loader:1235:19) at mod.require (C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\next\dist\server\require-hook.js:65:28) at require (node:internal/modules/helpers:176:18) at Object. (C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules@module-federation\enhanced\dist\src\lib\container\ContainerExposedDependency.js:8:26) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\@module-federation\enhanced\dist\src\lib\container\ContainerExposedDependency.js', 'C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\@module-federation\enhanced\dist\src\lib\container\ContainerEntryModule.js', 'C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\@module-federation\enhanced\dist\src\lib\container\HoistContainerReferencesPlugin.js',
    'C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\@module-federation\enhanced\dist\src\wrapper\HoistContainerReferencesPlugin.js', 'C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\@module-federation\enhanced\dist\src\index.js', 'C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\@module-federation\nextjs-mf\dist\src\internal.js', 'C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\@module-federation\nextjs-mf\dist\src\plugins\NextFederationPlugin\next-fragments.js',
    'C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\@module-federation\nextjs-mf\dist\src\plugins\NextFederationPlugin\index.js', 'C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\node_modules\@module-federation\nextjs-mf\dist\src\index.js', 'C:\Users\H532304.GLOBAL\Desktop\ABC\test\remote\next.config.js' ] }

parag3638 avatar Feb 05 '24 23:02 parag3638

@parag3638 , I am also getting the same error. Please check this issue #3621

sathishkumar555 avatar Feb 09 '24 03:02 sathishkumar555

Same error with next v14. Help!

OscarJVD avatar Mar 04 '24 14:03 OscarJVD

put it in both .env and on the command line.

https://github.com/vercel/next.js/blob/135642b9df800433b42876f777f486aa3b610b93/packages/next/src/compiled/webpack/webpack.js#L6

Otherwise file git issue with vercel.

ScriptedAlchemy avatar Mar 05 '24 04:03 ScriptedAlchemy

put it in both .env and on the command line.

https://github.com/vercel/next.js/blob/135642b9df800433b42876f777f486aa3b610b93/packages/next/src/compiled/webpack/webpack.js#L6

Otherwise file git issue with vercel.

where should i add this in next.js there is no such file cale called webpack.js

sreeharinm avatar Apr 24 '24 13:04 sreeharinm

NEXT_PRIVATE_LOCAL_WEBPACK=true next dev

ScriptedAlchemy avatar Apr 25 '24 00:04 ScriptedAlchemy

Screenshot 2024-04-25 114747

error still showing

NEXT_PRIVATE_LOCAL_WEBPACK=true next dev

sreeharinm avatar Apr 25 '24 06:04 sreeharinm

I have the same problem, I comment what I have done to see if they can help me.

Create both Home and Reomte project with NextJS 14 + Typescript + App Router (/src/app/page.tsx)

I made the configuration indicated in this article: https://medium.com/@sarathdixit29/implementing-module-federation-in-next-js-with-typescript-and-eslint-ba6627a0686f

If I run it like this: npm run dev it gives me the same error as the friend who started this thread.

If I change the next.config.mjs file and pass it to anext.config.js and adjust the content as the article says and execute it and now I get this error:

npm run dev

[email protected] dev next dev -p 3001

(node:25736) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created) ▲Next.js 14.2.3

  • Local: http://localhost:3001
  • Environments: .env

✓ Starting... (node:8476) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created) Error: App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this at NextFederationPlugin.validateOptions (D:\Dev\workspace\ws-mentor-it\nextjs\module-federation\remote-app\node_modules@module-federation\nextjs-mf\dist\src\plugins\NextFederationPlugin\index.js :67:23) at NextFederationPlugin.apply (D:\Dev\workspace\ws-mentor-it\nextjs\module-federation\remote-app\node_modules@module-federation\nextjs-mf\dist\src\plugins\NextFederationPlugin\index.js :45:19) at createCompiler (D:\Dev\workspace\ws-mentor-it\nextjs\module-federation\remote-app\node_modules\next\dist\compiled\webpack\bundle5.js:28:1467450) at D:\Dev\workspace\ws-mentor-it\nextjs\module-federation\remote-app\node_modules\next\dist\compiled\webpack\bundle5.js:28:1467068 at Array.map () at createMultiCompiler (D:\Dev\workspace\ws-mentor-it\nextjs\module-federation\remote-app\node_modules\next\dist\compiled\webpack\bundle5.js:28:1467060) at create (D:\Dev\workspace\ws-mentor-it\nextjs\module-federation\remote-app\node_modules\next\dist\compiled\webpack\bundle5.js:28:1467932) at webpack (D:\Dev\workspace\ws-mentor-it\nextjs\module-federation\remote-app\node_modules\next\dist\compiled\webpack\bundle5.js:28:1468341) at f (D:\Dev\workspace\ws-mentor-it\nextjs\module-federation\remote-app\node_modules\next\dist\compiled\webpack\bundle5.js:28:895636) at HotReloaderWebpack.start (D:\Dev\workspace\ws-mentor-it\nextjs\module-federation\remote-app\node_modules\next\dist\server\dev\hot-reloader-webpack.js:859:51)

How do I make it not look in the "pages" folder but instead look for them in src/app/page.tsx?

widipa avatar May 11 '24 04:05 widipa

Delete the app folder and only use pages.

ScriptedAlchemy avatar May 11 '24 06:05 ScriptedAlchemy