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

Dependencies from local package layer not installed/found #19124

Closed
niklaswolf opened this issue Feb 17, 2023 · 15 comments
Closed

Dependencies from local package layer not installed/found #19124

niklaswolf opened this issue Feb 17, 2023 · 15 comments

Comments

@niklaswolf
Copy link

Environment

  • Operating System: Darwin
  • Node Version: v18.13.0
  • Nuxt Version: 3.1.1
  • Nitro Version: 2.1.1
  • Package Manager: npm@8.19.3
  • Builder: vite
  • User Config: extends, shopware, modules, i18n
  • Runtime Modules: modules/domainRuntimeInfo
  • Build Modules: -

Reproduction

See bug report

Describe the bug

When using a local package as a nuxt layer, the dependencies do not get installed. Because of that, a module installed and registered in the layer will not be available in the project using the layer and result in the error message

ERROR Cannot find module 'XYZ'

I tried adding the layer package also a local dependency of the project, like so , but no success either.

I could obviously add the dependency to the project itself, too, but that's not the point of layers am I right?

Additional context

Layer package nuxt.config.js

modules: [
    'the-module-package',
  ],

Project using the layer nuxt.config.js

extends: ['../my-layer']
modules: [],

Logs

No response

Copy link
Member

This is a currently documented limitation of layers: https://nuxt.com/docs/getting-started/layers#layers. We can track support in #13367.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Feb 17, 2023
@samuveth
Copy link

@danielroe sorry, but where exactly is that documented on the page you linked?

@danielroe
Copy link
Member

Sorry, should have linked https://nuxt.com/docs/guide/going-further/layers

@basemkhirat
Copy link

Thanks for awesome Layers feature of Nuxt. I have a question.

Is auto-installing feature working in Nuxt modules?

As example, If the module is placed in a relative path in filesystem, Nuxt - in this case - will auto install the module depencies with base project?

@danielroe
Copy link
Member

No, Nuxt will not auto-install module dependencies; you can use your package manager to do that, though. yarn, pnpm and npm all support workspaces natively.

@avxkim
Copy link

avxkim commented Mar 12, 2024

@danielroe do i understand correctly, that we have to manually install packages are being used in a layer on our main app, that extends that layer?

For example:
Layer: has @nuxtjs/tailwind module installed,
App: must install @nuxtjs/tailwind either

That's expected behavior?

@pi0
Copy link
Member

pi0 commented Mar 12, 2024

New answer. With latest deps, you can opt-in to install:

extends: [
  ['../my-layer', { install: true }]
]

@avxkim
Copy link

avxkim commented Mar 12, 2024

@pi0 i just removed dependency from App and tried to start it pnpm dev:
got an error: "Cannot start nuxt: Cannot find module '/Users/alexanderkim/Sites/bazarjoq-new/nuxt-icon' "

this nuxt-icon is installed in layer in dependencies.

@DanCuatro
Copy link

I also have

extends: [
  ['../my-layer', { install: true }]
]

but it's throwing this error:

Cannot find module 'C:/laragon/www/test-layer/nuxt-icon'

@dsvgl
Copy link

dsvgl commented Apr 3, 2024

It would be very great to have this. We want to migrate our nuxt2 monorepo with 20 apps to nuxt 3 and managing 20 package.json deps is not something I'm looking forward to 🫣

@pi0
Copy link
Member

pi0 commented Apr 4, 2024

@avxkim @DanCuatro if you can reproduce, please make a new issue 🙏🏼

@ricardoprins-paqt
Copy link

Hey @pi0, it looks like @MuhammadM1998 has made a new issue with example repositories: #26479

I'm running into the same problem, even with completely fresh repositories. Could someone look into this? It would be greatly appreciated. :)

@Brads3290
Copy link

Brads3290 commented Apr 28, 2024

The ongoing issue here seems to be about dev dependencies specifically. Runtime dependencies do work fine as @pi0 said.

See my comment here and #26980.

@avxkim
@DanCuatro
@ricardoprins-paqt

@MuhammadM1998
Copy link
Contributor

@Brads3290 It's not about devDeplendencies. I saw your issue and that's actually the expected & documented behavior as others commented in the issue and not a bug. I created an issue with reproductions for this #26479

@Brads3290
Copy link

@MuhammadM1998 My mistake.

I assumed since it was a module that you were trying to depend on in your layer, that it was installed as a dev dependency (since nuxi module add does that by default). I see you've added it under dependencies in your layer, though.

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