Skip to content

Catch all routes gives error: Expected "0" to be defined #2496

Closed
nuxt/nuxt
#4394
@Livog

Description

@Livog

Version

3.0.2

Reproduction link

https://codesandbox.io/s/y22y9m738v

Steps to reproduce

Hello!

I use nuxt.js with this folder structure.

| - pages
|____ _.vue
|__ order
|____ _id.vue
|__coach
|____ _slug.vue

Which generates:

routes: [{
      path: "/coach/:slug?",
      component: _53d49874,
      name: "coach-slug"
    }, {
      path: "/order/:id?",
      component: _0fe25cac,
      name: "order-id"
    }, {
      path: "/*",
      component: _4a6e1890,
      name: "all"
    }],

and it gives me this error:

[nuxt] Error while initializing app TypeError: Expected "0" to be defined
    at app.js:3259
    at app.js:1391
    at Array.map (<anonymous>)
    at _callee5$ (app.js:1390)
    at tryCatch (commons.app.js:5425)
    at Generator.invoke [as _invoke] (commons.app.js:5659)
    at Generator.prototype.(:3000/anonymous function) [as next] (http://localhost:3000/_nuxt/commons.app.js:5477:21)
    at asyncGeneratorStep (commons.app.js:12)
    at _next (commons.app.js:34)

This does not happen in [email protected].
Rolling back with adding this to the package.json solves it for now (if anyone want a solution.)

"resolutions": {
    "vue-router": "3.0.1"
  },

This error is caused because I have a catch all / fallback route. I have tested in multiple Node versions and Nuxt version.

What is expected?

Catch all routes working without error.

What is actually happening?

Catch all routes give a error message.


Related: #724

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions