nuxt.options._layers is not iterable in v3.0.0
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 285
- Forks
- 33
- Avg merge
- 22h 38m
- Merged PRs (30d)
- 3
Description
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
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.4uses versionv3.8.2of@nuxt/kit - Version
v3.0.0uses versionv3.9.1of@nuxt/kit. - The
installModulefunction inv3.9.1depends on the contents of thenuxt.options._layersproperty. L19 - The
nuxt.options._layersproperty is mocked by@nuxt/bridgebut only indevenvironment or during thebuildprocess. L61 - This is the reason why the
nuxt.options._layersproperty isundefinedwhen the server is started.
Proposed solution:
- We need to mock _layers for nitro and auto-imports outside the
buildModulesfunction. - This solves the issue locally
Additional context
No response
Logs
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/bridge/module.cjs at the linked _layers mock and packages/kit/src/module/install.ts at installModule. Reproduce the production path with yarn build followed by yarn start, then verify that the server starts without the nuxt.options._layers error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxtjs, typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100