Repository router-module


venturion posted a new question

router-module • 21 days ago

How extends routes inside a module (client and server) sides?

How can i extends de main routes inside a custom nuxt module?

i've tried to do:


function but it only adds the route to the client side

when refresh the route disappears

can anyone help?


shandianshi posted a new question

router-module • a month ago

Problem while loading external sources in Nested Routes

I checked the tutorial from Nuxt officical page and write a nested route similar to the sample. However while i'm using external js in local setting form(,it seems not loading external js in local setting through this.$router.push({path:***}) or this.$router.push(name:childviewName).

But the url has directed to the page. And the exrernal sources written in local setting form can be loaded after directly refreshing the page. Though writting external sources in Global Settings can work(I've tested) ,but i guess that's not a good way to solve this problem.


nathangathright posted a new question

router-module • 2 months ago

Does router-module support alias?

Is it possible to use vue-router's aliasing in Nuxt with router-module? If not, is there another way to alias routes?


sobolevn posted a new bug report

router-module • 2 months ago

bug router.js is ignored from eslint-loader linting

What I expect to happen

I expect that my pre loader configuration will lint this file.

That's how I configure it:

        // Enabling eslint in nuxt.config.js:
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/

What actually happens

router.js is just ignored from linting.
You can write any styles you want, nothing will happen.

It only happens with the file. Other files are linted as usual.

Steps to reproduce

  1. Install
  2. Mess up something inside router.js for example: mode:'history', (no spaces)
  3. Run yarn dev

There will be no error. But there should be one.


I guess it happens because webpack does not actually require() this file during the client build.


I have tried to submit a bug via cmty twice! At the first try it just removed everything I had and showed me this message (I was unable to select any version):
2018-06-09 22 21 19

Then it just went offline (but I have already copied my issue text this time!):
2018-06-09 22 22 31


mosinve posted a new question

router-module • 3 months ago

Adding custom data fo routes

Is there any possibility to add custom data to generated routes, besides extendRoutes?

I want to auto-generate nav menu in my Nuxt application, and i need to set a title to each route.


mariojankovic posted a new question

router-module • 3 months ago

Add option to nest <nuxt /> tag inside pages

Based on LinusBorg's answer here it would be good to have the option to specify another <nuxt /> tag inside the index.vue page for the corresponding route. For example, if my routes look like this:

- somepage.vue
- items/
  - _slug.vue
  - index.vue (the one with <nuxt /> tag)

It would be nice to just append that content into items/index.vue instead of swapping all the content from _slug.vue with index.vue.
Is this already possible? If yes, what was I missing?

This would prove super useful for galleries for example, or any kind of modal content/content that would need to show the parent routes content in the background.


venturion posted a new question

router-module • 6 months ago

how get router instance on a middleware?

how get router instance on a middleware?


wellnine posted a new question

router-module • 6 months ago

Lazy loading

Hi there. Thank you for your module.
I am trying to use it in my project instead pages mechanism. Everything are going fine except lazy-loading (eg. code splitting)

I tried to use this configuration, like in Vue-router docs but it doesn't work somehow

```import Vue from "vue"
import Router from "vue-router"

import Main from "~/components/Main"

const Customer = () => import("~/components/customer/index.vue");

// import Customer from "~/components/customer";
import Overview from "~/components/customer/overview";
import Profile from "~/components/customer/profile";
import Cards from "~/components/customer/cards";


export function createRouter() {
return new Router({
mode: "history",
routes: [
path: "/",
component: Main
path: "/customer",
component: Customer,
children: [
path : "",
component : Overview
path : "profile",
component : Profile
path : "cards",
component : Cards

When I tried to load the Customer module I got this issue
`Failed to mount component: template or render function not defined.`

My component is deadly simple

<template> <router-view></router-view> </template>

<script lang="ts"> import Vue from "vue"; import Component from "nuxt-class-component"; @Component export default class extends Vue {} </script>


could you, please, help me with this issue? May be I'm doing something wrong.


jasonc08 posted a new question

router-module • 6 months ago

typescript does not work

ERROR Nuxt error
Error: [nuxt-router-module] Please create a router.js file in your source folder.


cbodin posted a new question

router-module • 7 months ago

SPA in subdirectory/router base.

Generating an SPA with a router base set will automatically add a <base href=""> so the application can be loaded in a subdirectoy.

Can this be accomplished when using the router-module or will i need to set the base-href and rewrite all script tags myself?


xxxxxMiss posted a new question

router-module • 7 months ago

router-module not working in latest version

my router.js is written like this:

import rewardRoutes from '~/routers/reward-router'
import taskRoutes from '~/routers/task-router'

const routes = [
    path: '/',
    component: index,
    children: [
        path: '',
        component: index
        path: 'task',
        component: task,
        children: taskRoutes
        path: 'reward',
        component: reward,
        children: rewardRoutes
export function createRouter () {
  return new VueRouter({
    mode: 'history',

now, when navigate to a page, the url is changed, but the target page is not rendered.


hauleth posted a new question

router-module • 7 months ago

Custom meta value do not work with Nuxt 1.1.1

With 1.1.1 meta field of vm.$route is set to [ {} ] for some reason.


feedgit posted a new question

router-module • 9 months ago

Best way to Write API in Nuxt and Router Module?

I'm finding best way to write API.
Currently, i write api like this:

  <div class="row flex">
  import axios from 'axios'
  import Item from '~/components/feeds/Post.vue'
  export default {
    data () {
      return {
        data: {}
    mounted () {
    methods: {
      async asyncData (params) {
        let { data } = await axios.get('http://localhost:8000/api/v1/feeds/' + this.$ + '/') = data
    components: {
      'post-detail': Item

But when I get children data: {{data.user.username}}, the data.user goes undefined. Is this the best way to write API data in Nuxt and Router Module?


johnRivs posted a new question

router-module • 10 months ago

Module not found: Error: Can't resolve 'fs'

When I nuxt or nuxt build, I get this error:

ERROR in ./node_modules/@nuxtjs/router/dist/index.js
Module not found: Error: Can't resolve 'fs' in 'MY_PROJECT\node_modules\@nuxtjs\router\dist'
 @ ./node_modules/@nuxtjs/router/dist/index.js 4:9-22
 @ multi vue vue-router vue-meta vuex @nuxtjs/router
Error: Webpack build exited with errors
    at MY_PROJECT\node_modules\nuxt\lib\builder\builder.js:498:27
    at emitRecords.err (MY_PROJECT\node_modules\webpack\lib\Compiler.js:269:13)
    at Compiler.emitRecords (MY_PROJECT\node_modules\webpack\lib\Compiler.js:375:38)
    at emitAssets.err (MY_PROJECT\node_modules\webpack\lib\Compiler.js:262:10)
    at applyPluginsAsyncSeries1.err (MY_PROJECT\node_modules\webpack\lib\Compiler.js:368:12)
    at next (MY_PROJECT\node_modules\tapable\lib\Tapable.js:218:11)
    at Compiler.compiler.plugin (MY_PROJECT\node_modules\webpack\lib\performance\SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (MY_PROJECT\node_modules\tapable\lib\Tapable.js:222:13)
    at Compiler.afterEmit (MY_PROJECT\node_modules\webpack\lib\Compiler.js:365:9)
    at require.forEach.err (MY_PROJECT\node_modules\webpack\lib\Compiler.js:354:15)
    at MY_PROJECT\node_modules\async\dist\async.js:421:16
    at iteratorCallback (MY_PROJECT\node_modules\async\dist\async.js:998:13)
    at MY_PROJECT\node_modules\async\dist\async.js:906:16
    at MY_PROJECT\node_modules\graceful-fs\graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)
npm ERR! errno 1
npm ERR! [email protected] build: `nuxt build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\John\AppData\Roaming\npm-cache\_logs\2017-10-18T12_11_19_032Z-debug.log

javialon26 posted a new question

router-module • a year ago

question lazy load

hello @Atinux with this module are the routes still lazy?


robyedlin posted a new question

router-module • a year ago

Router module with mode: 'spa'

I'm getting an error that there is a missing /dist/index.html file when running a build with mode: 'spa' in nuxt.config.js.

Am I missing a config, or is this a bug?


jamestowers posted a new question

router-module • a year ago

Get routes.js file from api call

I posted about this here but thought I'd try again here as its more relevant.

I'm running Nuxt as the frontend to a cms so need to get the pages from an api call, can I get the pages from nuxtServerInit then loop through them in router.js to create the routes.

Or I could programatically create a valid routes.js on the CMS side if i could then fetch it from Nuxt somehow.



robyedlin posted a new question

router-module • a year ago

nuxt generate - no such file or directory

With fresh Nuxt and router-module 1.0.1, nuxt generate produces the following error:

Generating routes
{ Error: ENOENT: no such file or directory, lstat '/home/ubuntu/workspace/dist/index.html'
    at Error (native)
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/home/ubuntu/workspace/dist/index.html' }

nusson posted a new question

router-module • a year ago

npm run generate error on routes

Since I used your module, I'm not able to generate a static website `yarn run generate'

here the error

TypeError: Cannot read property 'forEach' of undefined
    at flatRoutes (/Users/nicolashusson/www/shingrix/htdocs/node_modules/nuxt/dist/nuxt.js:1288:9)
    at Generator._callee2$ (/Users/nicolashusson/www/shingrix/htdocs/node_modules/nuxt/lib/builder/generator.js:62:66)
    at tryCatch (/Users/nicolashusson/www/shingrix/htdocs/node_modules/nuxt/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (/Users/nicolashusson/www/shingrix/htdocs/node_modules/nuxt/node_modules/regenerator-runtime/runtime.js:299:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/nicolashusson/www/shingrix/htdocs/node_modules/nuxt/node_modules/regenerator-runtime/runtime.js:117:21)
    at step (/Users/nicolashusson/www/shingrix/htdocs/node_modules/nuxt/dist/nuxt.js:954:30)
    at /Users/nicolashusson/www/shingrix/htdocs/node_modules/nuxt/dist/nuxt.js:965:13

indeed, in node_modules/nuxt/dist/nuxt.js, function flatRoutes(router)
router is undefined…


greenkeeper[bot] posted a new question

router-module • a year ago

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.