nuxt: Nuxt Layers + Npm Workspaces(Monorepo) Doesn't work only in Dev Mode

Environment

  • Operating System: Darwin
  • Node Version: v19.3.0
  • Nuxt Version: 3.8.0
  • CLI Version: 3.9.1
  • Nitro Version: 2.7.2
  • Package Manager: npm@9.3.1
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/halilyuce/monorepo

Describe the bug

Here is my monorepo structure:

image

I created a monorepo with npm workspaces and extended apps in the portal(main app) thanks to nuxt layers. Everything works as expected in production mode but not in dev mode?

When I run the project in dev mode, I do not receive any errors. It stays on the nuxt loading screen and the computer starts to heat up seriously and the fans become loud, probably a memory problem.

I have a decent laptop, according to my research, this problem occurs because the node_modules location changes when using monorepo. I applied dozens of solutions for this, but none of them worked.

image

image

Additional context

No response

Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 19 (12 by maintainers)

Most upvoted comments

So it requires deeper investigation but again it’s not Nuxt issue 😃

Yep. It works in this case. At least it can render the 404 page 😃 image image

Oh, thank you! ❤️

There are so many things missing in your example such as windiCSS. I’m starting to think maybe windiCSS is causing a problem?

True. I tried to isolate everything and make it as simple as possible. Let me check again your repro. I don’t think it’s windi

Yep. It’s possible in npm as well. theguriev/monorepo-explanation#1

Have fun 😃

So it’s definitely no Nuxt issue. 😃

You are amazing mate, you put in a lot of effort! 😃 I installed pnpm while you were working on this and applied it to the current project, the problem is the same, I think we are looking in the wrong place. There are so many things missing in your example such as windiCSS. I’m starting to think maybe windiCSS is causing a problem?

Yep. It’s possible in npm as well. https://github.com/theguriev/monorepo-explanation/pull/1

Have fun 😃

So it’s definitely no Nuxt issue. 😃

Let me check if it’s possible with npm workspaces. I believe it is but not sure 😃

Few mins…

Here it is.

git clone git@github.com:theguriev/monorepo-explanation.git && cd monorepo-explanation && pnpm i && cd portal && pnpm run dev

Just run this in terminal and open http://localhost:3000/first-ui

image

Well yes. Looks like there is an infinite loop when it’s try to resolve aliases. #portal is trying to resolve #first-ui and #first-ui has some links to the #portal. It’s a never-ending cycle. I’ll prepare a minimal repro with fix in few minutes.