Skip to content

Warning vue router #57

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

Closed
javialon26 opened this issue Mar 28, 2018 · 28 comments
Closed

Warning vue router #57

javialon26 opened this issue Mar 28, 2018 · 28 comments

Comments

@javialon26
Copy link

javialon26 commented Mar 28, 2018

In all routes with more than one level i have this warning:

[vue-router] Route with name 'usuario-editar-perfil-es-es' does not exist

Examples:

Route: http://localhost:3000/usuario/editar-perfil
[vue-router] Route with name 'usuario-editar-perfil-es-es' does not exist

Route: http://localhost:3000/usuario/mis-anuncios
[vue-router] Route with name 'usuario-mis-anuncios-es-es' does not exist

But in routes with only one level it is okay, for example:

http://localhost:3000/ayuda
http://localhost:3000/quienes-somos

My Nuxt version is 1.4.0 and nuxt-i18n version is 2.9.1.
Configurations:

  defaultLocale: 'es',
  locales: [
    {
      code: 'es',
      iso: 'es-ES',
      name: 'Español',
      langFile: 'es-ES.js'
    },
    {
      code: 'en',
      iso: 'en-US',
      name: 'English',
      langFile: 'en-US.js'
    }
  ],
  loadLanguagesAsync: true,
  langDir: 'locales/'
This question is available on Nuxt.js community (#c46)
@ghost ghost closed this as completed Mar 28, 2018
@ghost ghost added the cmty:question label Mar 28, 2018
@paulgv paulgv reopened this Mar 28, 2018
@paulgv
Copy link
Collaborator

paulgv commented Mar 28, 2018

Hi @javialon26, what does the files structure look like in your pages directory?

@javialon26
Copy link
Author

javialon26 commented Mar 28, 2018

@paulgv this is the pages directory and now the same warning happens with all pages inside ayuda directory.

screenshot from 2018-03-28 11 04 30

The warning appears when i enter the route.

@qqil
Copy link

qqil commented Apr 4, 2018

@moecasts
Copy link

moecasts commented Apr 5, 2018

I fixed the problem by rewrite this code.

https://github.com/nuxt-community/nuxt-i18n/blob/38325e2a0b49b2abe25a6abaed663fa3aa7f27f4/lib/templates/i18n.routing.middleware.js#L37

const routeName = route && route.name ? app.getRouteBaseName() : 'index';

@javialon26
Copy link
Author

javialon26 commented Apr 7, 2018

@moecasts @paulgv

After the update the warning is still showing but i found the problem.

I have a custom breadcrumb component with a localePath method in a nuxt-link tag. The name param is taken from the store and the value is loaded in a middleware with the value of route.name, this value already has -es or -en suffix and when is passed to localePath the suffix is added again.

This will be fixed or i need to take care of this in my own code?

Thank you!

@javialon26
Copy link
Author

any news on this?

@paulgv
Copy link
Collaborator

paulgv commented Apr 16, 2018

Hi @javialon26 !
Sorry I've not been able to spend much time on the module lately.
If your paths are already localized, you don't need to use localePath, you can simply pass them as is to <nuxt-link>, any way you could do that?

@javialon26
Copy link
Author

@paulgv you right, now i pass the route name directly to nuxt-link and everythings is ok. thank you!

@Extarys
Copy link

Extarys commented Apr 26, 2018

I have the same issue, I opened another ticket for it though. Can't make i18n to work (Cannot continue my project without it) - Ignore the first part I was setting it up the 'old' way (I found that 6 hours later :P)

@paulgv paulgv closed this as completed Aug 26, 2018
@trylovetom
Copy link

trylovetom commented Sep 12, 2018

this.$router.push(this.localPath('/path'))
doesn't work.

I get the same warnging again.

@georgefeast
Copy link

@paulgv I'm still experiencing this issue with the '[vue-router] Route with name x does not exist' whenever I manually set enabled locales in the component. It seems the error is generated in every case where localePath is used: the only way to get rid of the warnings altogether is if I set SEO: false, remove all links with localePath and remove the language switcher so it seems like a warning is generated anywhere localePath is called. Do you have any idea how to fix this? Or @moecasts, could you repost the change you mentioned here #57 (comment) ?

@pkorzh
Copy link

pkorzh commented Oct 28, 2018

i have the same problem, usually happens after rebuild.

i was able to narrow down the problem to this code:

this.extendRoutes((routes) => {
  const localizedRoutes = makeRoutes(routes, {
    ...options,
    pagesDir
  })
  routes.splice(0, routes.length)
  routes.unshift(...localizedRoutes)
});

when rebuild starts routes already contains localized routes.

@sukhanovr
Copy link

The same for me, as @pkorzh has, started after I’ve updated nuxt to v2.*

@mathieubellon
Copy link

mathieubellon commented Nov 3, 2018

Same here but only with hash key as @pkorzh and @cyxapb1280

:to="localePath({name:'index'},$i18n.locale)" > no warnings
:to="localePath({name:'index', hash:"#section-prices"},$i18n.locale)" > warnings crazy

Also with Nuxt 2.*, I'll try Nuxt 1

EDIT
Seems that even without localePath that :to="{name:'index', hash:"#section-prices"}" triggers weird errors also

@phortx
Copy link

phortx commented Apr 11, 2019

So what is the solution for this issue when it's closed?

I get millions of these warnings because the generation of the alternate links.

@phortx
Copy link

phortx commented Apr 11, 2019

Found #14

@elinardo10
Copy link

i'm with this problem. Anybody has solution to fix this?

@dilikpulatov
Copy link

dilikpulatov commented Dec 25, 2019

// Routes generation strategy, can be set to one of the following:
// - 'no_prefix': routes won't be prefixed
// - 'prefix_except_default': add locale prefix for every locale except default
// - 'prefix': add locale prefix for every locale
// - 'prefix_and_default': add locale prefix for every locale and default
strategy: 'no_prefix'

@tvld
Copy link

tvld commented Jan 6, 2020

Problem still persists. strategy: 'no_prefix' is not ideal option as you loose all links.

But so far all I can do as localePath('index') is buggy.) I got all the time :

[vue-router] Route with name '/my_page___nl' does not exist vue-router.esm.js:16

@ianfortier
Copy link

You can fix this problem by installing @nuxtjs/router-extras and set a custom name for the route like this :
image

@Elvincth
Copy link

Elvincth commented Feb 26, 2021

Same problem here [vue-router] Route with name 'index___en' does not exist, when would this be fix?

@dilikpulatov
Copy link

Снимок экрана от 2021-02-27 04-25-53
Снимок экрана от 2021-02-27 04-26-33
Снимок экрана от 2021-02-27 04-26-50

@jwittekind
Copy link

@paulgv The described issue in this thread is still existent, though it got closed.
Unfortunately there is no documented solution or reason which solves the mentioned issue.
Why is this ticket closed? Can we expect a bugfix for this within this i18n module or is there any specific implementation of how to avoid the output of countless warnings?

@rchl
Copy link
Collaborator

rchl commented Apr 7, 2021

This issue is very old and a lot has changed since the initial report so I'm not sure if your issue is even related.

Please create a new issue for your problem with a reproduction repo (or codesandbox).

@jonalxh
Copy link

jonalxh commented May 12, 2021

Is is still happening with the latest version of nuxt and router.

@adhamfarrag
Copy link

@paulgv we just need to disable the warnings. 2022 and it's still going on.

@renaudham
Copy link

to all, in my case it was just about redoing a npm run dev / build and all is ok

@surge-squirrel
Copy link

This continued on August 9, 2023 @paulgv

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

No branches or pull requests