Skip to content

vue-i18n does not work with Nuxt 3.7.2 without transpiling #1546

@mcrapts

Description

@mcrapts

Reporting a bug?

Integrating vue-i18n into a Nuxt 3.7 application according to the instructions results in the following error when building and running the application:

[nuxt] [request error] [unhandled] [500] Cannot find module '/home/projects/github-hnz7et-dysose/.output/server/chunks/dist/vue-i18n.runtime.mjs' imported from /home/projects/github-hnz7et-dysose/.output/server/chunks/app/server.mjs

It works fine in dev.

Expected behavior

No error.

Reproduction

https://stackblitz.com/edit/github-hnz7et-dysose?file=nuxt.config.ts

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.20.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.6.10 - /usr/local/bin/pnpm
  npmPackages:
    @intlify/unplugin-vue-i18n: ^1.2.0 => 1.2.0 
    vue-i18n: ^9.4.0 => 9.4.0 

Screenshot

No response

Additional context

It might be just a documentation error according Daniel Roe from Nuxt: nuxt/nuxt#23180 (comment)

This workaround seems to work without issues.

  // https://nuxt.com/docs/api/configuration/nuxt-config
  import VueI18nPlugin from '@intlify/unplugin-vue-i18n';
  
  export default defineNuxtConfig({
    devtools: { enabled: true },
+   build: {
+     transpile: [/vue-i18n/]
+   },
    vite: {
      plugins: [
        VueI18nPlugin.vite({
          /* options */
  
        }),
      ],
    },
  });

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions