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

Impossible to have Nuxt 2 and Nuxt 3 in same monorepo: Nuxt 3 can't do postinstall #12331

Closed
Suniron opened this issue Jan 19, 2023 · 12 comments
Closed

Comments

@Suniron
Copy link

Suniron commented Jan 19, 2023

Environment

Windows 11 > WSL2 Ubuntu


  • Operating System: Linux
  • Node Version: v18.11.0
  • Nuxt Version: 2.15.8
  • Nitro Version: 1.0.0
  • Package Manager: pnpm@7.14.2
  • Builder: webpack
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

Minimal reproduction here: https://github.com/Suniron/monorepo-nuxt2-nuxt3-problem

Try to install with pnpm install in root folder

Describe the bug

Hey,

I'm working on a monorepo (with turborepo) of a big project using Nuxt 2 as web interface.

I need to create a second web app which using Nuxt 3 but i can't start this app in the monorepo, i got this error when i try to install the project (pnpm i at root):

Scope: all 7 workspace projects
Lockfile is up to date, resolution step is skipped
Already up to date
apps/nuxt3-app postinstall$ nuxt prepare
│ Nuxi 3.0.0
│ ℹ Client built in 7475ms
│ ℹ Building server...
│  ERROR  [commonjs--resolver] Missing "./server-renderer" export in "vue" package
│  ERROR  Missing "./server-renderer" export in "vue" package

I think the problem is because the root node_modules is shared.

I just pushed a simple version of my project here which reproduce the problem:

https://github.com/Suniron/monorepo-nuxt2-nuxt3-problem

Additional context

No response

Logs

No response

@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
@Baroshem
Copy link
Contributor

Hey,

I dont think that this can be fixed as Nuxt 2 and Nuxt 3 have several different dependencies (including different versions of libraries). Because of that fixing this might be very difficult (not to mention that it is a rather not common use case 😉)

I would recommend to have apps in a separate repositories as this can cause even more issues later on.

@danielroe
Copy link
Member

This doesn't look like a Nuxt issue to me. I believe you will need to configure your dependency hoisting settings within pnpm: https://pnpm.io/npmrc#dependency-hoisting-settings.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2023
@Suniron
Copy link
Author

Suniron commented Jan 22, 2023

OK I will try to configure pnpm. Thanks for tips :-)

@Suniron
Copy link
Author

Suniron commented Jan 31, 2023

Mmmh i don't understand how can i correctly set the hoisting..

@manzoliric
Copy link
Contributor

manzoliric commented Feb 18, 2023

@Suniron did you fixed? I'm with this same problem, i cannot use nuxt-2 and nuxt-3 in the same project using Pnpm 😢

@Suniron
Copy link
Author

Suniron commented Feb 18, 2023

No, it's not fixes yet.

Currently, my nuxt 3 app is in Dev only I can't build it but I can build and Dev on Nuxt bridge projet (I migrate my nuxt 2 to nuxt bridge since I got this problem).
The Dev mode is OK with my Nuxt 3 app.

I dont need the production build before 2/3 next months, but I hope to find a solution soon 🤞

@steffendybvik
Copy link

I have the same issue, haven't found a configuration that work yet. If anyone has a way to accomplish this; please do tell

@manzoliric
Copy link
Contributor

I created this discussion in pnpm, maybe someone helps!
pnpm/pnpm#6104

@Suniron
Copy link
Author

Suniron commented Feb 27, 2023

Thanks ! I'm always stucked with this problem..

@cjpearson
Copy link

@danielroe I'm also running into this issue with Yarn, so I think this might be a nuxt rather than pnpm issue. Even when the correct versions of nuxt and @nuxt/kit are in the local node_modules, nuxt tries to load them from the root. It looks to me like it might be related to unjs/mlly#158

@manzoliric
Copy link
Contributor

@steffendybvik @Suniron, did you find a way to fix this problem?

@Suniron
Copy link
Author

Suniron commented Nov 30, 2023

Not really, I had to put my Nuxt Bridge projet into a ''standalone'' folder (inside my monorepo to have all my apps in the same git project).

But I can't use packages :-(

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

No branches or pull requests

6 participants