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

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

Closed
Livog opened this issue Nov 23, 2018 · 2 comments · Fixed by nuxt/nuxt#4394
Closed

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

Livog opened this issue Nov 23, 2018 · 2 comments · Fixed by nuxt/nuxt#4394

Comments

@Livog
Copy link

Livog commented Nov 23, 2018

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 vue-router@3.0.1.
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

@aldarund
Copy link
Contributor

could be something caused by this #1995

@manniL
Copy link

manniL commented Nov 23, 2018

https://codesandbox.io/s/54v0vl1rzn

Can't repro it with pure Vue + VueRouter. Might be an interop issue between Nuxt and the new(est) VueRouter 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants