I18n-module: Failure with nuxt-svg-sprite

Created on 7 Aug 2020  ·  10Comments  ·  Source: nuxt-community/i18n-module

Version

nuxt-i18n: 6.13.7
nuxt: 2.14.1

Nuxt configuration

mode:

  • [] universal
  • [x] spa

Nuxt-i18n configuration

Reproduction Link

Steps to reproduce

npm run dev

What is Expected?

The dev server gets started

What is actually happening?

ℹ Preparing project for development                                                                                                                                                         10:01:21
ℹ Initial build may take a while                                                                                                                                                            10:01:21
✔ Builder initialized                                                                                                                                                                       10:01:21

 ERROR  ENOENT: no such file or directory, open '/some/directory/.nuxt/nuxt-svg-sprite-icons-list.vue'                                                        10:01:21

  at Object.openSync (fs.js:443:3)
  at readFileSync (fs.js:343:35)
  at exports.extractComponentOptions.path (node_modules/nuxt-i18n/src/helpers/components.js:17:45)
  at buildLocalizedRoutes (node_modules/nuxt-i18n/src/helpers/routes.js:32:21)
  at exports.makeRoutes (node_modules/nuxt-i18n/src/helpers/routes.js:150:46)
  at Object.moduleContainer.extendRoutes.routes (node_modules/nuxt-i18n/src/core/hooks.js:47:33)
  at Object.extendRoutes (node_modules/@nuxt/utils/dist/utils.js:1860:25)
  at Builder.resolveRoutes (node_modules/@nuxt/builder/dist/builder.js:5867:56)

This was working until the recent updates to nuxt-i18n.

bug 🐛

All 10 comments

Provide a reproduction please.

I don't see why would you have a Vue file in .nuxt directory and why this module would try to parse it.

@rchl I disabled nuxt-i18n in the module section of nuxt.config.js file and the dev server started fine.

It seems the file mentioned in the error above is create during the build process. I'll try to setup a codesandbox which demonstrates this error.

I can actually reproduce this by adding https://github.com/nuxt-community/svg-sprite-module to the project but I can reproduce even in much older nuxt-i18n versions (even 6.10.0) so it doesn't seem like a regression caused by this module. Maybe the SVG module itself changed something.

EDIT: Or something could have changed in new Nuxt versions.

The svg-sprite-module copies a vue file to the build dir and extends route to include that file:
https://github.com/nuxt-community/svg-sprite-module/blob/0114b21fa1078b8c94424453a8f6073ef520669e/lib/module.js#L50-L63

The problem is that this module also extends the routes and by the time it gets to do that, the route that svg module inserted is there but the file is not there yet. So this module crashes on trying to read the file.

One quick and dirty solution I could use is to just ignore non-existent routes.

@rchl thanks for looking into it!

So one of the quirks with getting the two to play together (going back at least 4 months) was to add @nuxtjs/svg-sprite in the nuxt.config.js file _after_ nuxt-i18n. However, this setup stopped working just recently (things were working fine until 6.13.1 atleast).

EDIT:- I had it working until at least nuxt 2.14.0 as well
EDIT2:- The generate command seems to works fine

Right, that makes sense. This module has moved the code that ran at build time to run from build:before hook. So that has changed the timings slightly.

The module system in Nuxt is a bit brittle and undefined when it comes to multiple modules interacting with each other...
I suppose I will just have to ignore missing routes...

@rchl is there a workaround for this that I could use in the meantime? Thanks!

If you are not using that function, you could set parsePages: false.

But I have fixed this anyway now.

Released in v6.13.8

Thanks a lot for the quick action!!

Was this page helpful?
0 / 5 - 0 ratings