typescript does not work

jasonc08
11
jasonc08
commented a year ago

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

0
Atinux
22.6k
Atinux
commented a year ago

Like it says, you have to manually create a router.js in your project directory.

0
riddla
0
riddla
commented 18 days ago

I think he was referring to using a router.ts instead of router.js. I tested this locally by changing the routerPath in the library itself and it worked without problems (in nuxt-ts context).

0
riddla
0
riddla
commented 18 days ago

@Atinux, should I open a pull request with detecting either a router.ts or router.js?

Something like …

  // [...]

  let routerPath = resolve(this.options.srcDir, 'router.js');
  if (!existsSync(routerPath)) {
    routerPath = resolve(this.options.srcDir, 'router.ts');
  }

  // Check if router.js is defined
  if (!existsSync(routerPath))
    throw new Error(
      '[nuxt-router-module] Please create a router.js (or router.ts) file in your source folder.'
    );

    // [...]
0
Informations
QuestionUnresolved
#c12 - Created a year ago