bridge icon indicating copy to clipboard operation
bridge copied to clipboard

FATAL nuxt.options.generate.routes is not iterable

Open SebbeJohansson opened this issue 3 years ago • 2 comments

Environment

Nuxt project info: 22:09:40


  • Operating System: Windows_NT
  • Node Version: v16.16.0
  • Nuxt Version: 2.16.0-27616340.013f051b
  • Package Manager: [email protected]
  • Builder: webpack
  • User Config: bridge, target, ssr, head, css, plugins, components, buildModules, modules, axios, generate, i18n, serverHandlers, devServerHandlers
  • Runtime Modules: @nuxtjs/[email protected], 8n
  • Build Modules: (), @nuxt/[email protected], module

👉 Report an issue: https://github.com/nuxt/framework/issues/new 22:09:40

👉 Suggest an improvement: https://github.com/nuxt/framework/discussions/new

👉 Read documentation: https://v3.nuxtjs.org

Done in 0.86s.

Reproduction

  • Create a nuxt bridge project.
  • Set it to "target: static" and "ssr: false".
  • Create a custom generate: { routes() } function.
  • ???
  • Notice that it cant generate routes and instead returns FATAL nuxt.options.generate.routes is not iterable

Describe the bug

No matter the output from routes() in generate it results in a stopped generate process. The error message is: image

Additional context

Even if i return an empty array it still doesn't let me generate.

Logs

yarn run v1.22.19
$ nuxi generate
Nuxt CLI v3.0.0-rc.6                                                                                                                                                                                                                                        22:08:11

 FATAL  nuxt.options.generate.routes is not iterable                                                                                                                                                                                                        22:08:15  

  at setupNitroBridge (/C:/Users/Sebastian/Documents/JavascriptProjects/Vrtx.ContentSystem/node_modules/@nuxt/bridge/dist/chunks/module.mjs:208:81)
  at /C:/Users/Sebastian/Documents/JavascriptProjects/Vrtx.ContentSystem/node_modules/@nuxt/bridge/dist/chunks/module.mjs:1227:15
  at node_modules\hable\dist\hable.js:1:990
  at node_modules\hable\dist\hable.js:1:208
  at async Nuxt.callHook (node_modules\hable\dist\hable.js:1:959)
  at async ModuleContainer.ready (node_modules\@nuxt\core-edge\dist\core.js:49:5)
  at async Nuxt._init (node_modules\@nuxt\core-edge\dist\core.js:346:5)

i Production build                                                                                                                                                                                                                                          22:08:15
i Bundling only for client side                                                                                                                                                                                                                             22:08:15  
i Target: static                                                                                                                                                                                                                                            22:08:15  

 WARN  Components directory not found: ~/components/storyblok                                                                                                                                                                                               22:08:15  

i Using components loader to optimize imports                                                                                                                                                                                                               22:08:15  
i Discovered Components: .nuxt/components/readme.md                                                                                                                                                                                                         22:08:15  
√ Builder initialized                                                                                                                                                                                                                                       22:08:15  
√ Nuxt files generated                                                                                                                                                                                                                                      22:08:15

● Client █████████████████████████ building (10%) 6/7 modules 1 active
 babel-loader › .nuxt\components\nuxt-link.client.js

SebbeJohansson avatar Aug 10 '22 20:08 SebbeJohansson

Nitro does not support receiving a function for generate.routes. Instead, you can use an async hook to add routes to the options.

danielroe avatar Aug 10 '22 20:08 danielroe

@danielroe Ah okay. An async hook where? Is there a documentation link I can look at?

SebbeJohansson avatar Aug 11 '22 13:08 SebbeJohansson