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

nuxt.options._layers is not iterable in v3.0.0 #1067

Open
Piscinelove opened this issue Jan 15, 2024 · 1 comment
Open

nuxt.options._layers is not iterable in v3.0.0 #1067

Piscinelove opened this issue Jan 15, 2024 · 1 comment

Comments

@Piscinelove
Copy link

Environment


  • Operating System: Linux
  • Node Version: v20.8.1
  • Nuxt Version: 2.17.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: pnpm@8.14.1
  • Builder: webpack
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

Edit currying-tdd-4qddcj

The error only occurs in production after running :

yarn build
yarn start

Describe the bug

I am in the process of updating a module in our company from v3.0.0-rc.4 to v3.0.0

We're not using nitro and vite yet, as we still have some work to do.

Our module installs other modules using installModule function from @nuxt/kit.

The following error occurs when launching the server after a production build :

yarn run v1.22.19
$ nuxt2 start

 ERROR  nuxt.options._layers is not iterable                        7:37:51 PM

  at installModule (node_modules/@nuxt/kit/dist/index.mjs:2409:32)

I traced the error back to its source

If I understand correctly,

  • Version v3.0.0-rc.4 uses version v3.8.2 of @nuxt/kit
  • Version v3.0.0 uses version v3.9.1 of @nuxt/kit.
  • The installModule function in v3.9.1 depends on the contents of the nuxt.options._layers property. L19
  • The nuxt.options._layers property is mocked by @nuxt/bridge but only in dev environment or during the build process. L61
  • This is the reason why the nuxt.options._layers property is undefined when the server is started.

Proposed solution:

  • We need to mock _layers for nitro and auto-imports outside the buildModules function.
  • This solves the issue locally

Additional context

No response

Logs

No response

@Piscinelove Piscinelove changed the title nuxt.options._layers is not iterable nuxt.options._layers is not iterable in v3.0.0 Jan 15, 2024
@wattanx
Copy link
Collaborator

wattanx commented Jan 16, 2024

I think we should create an issue on upstream for this.
https://github.com/nuxt/nuxt

Also, I think it is better to use @nuxt/kit with buildModules.
In nuxt 3, modules are build-time-only.
https://nuxt.com/docs/guide/concepts/modules#add-nuxt-modules
https://nuxt.com/docs/migration/module-authors#avoid-runtime-modules

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

2 participants