Skip to content

vue-i18n 8.28.2 not working with vite (Vue 2.7), error "Uncaught TypeError: Vue is undefined" #2009

@Thomas-1985

Description

@Thomas-1985

Reporting a bug?

I am migrating a vue-cli v5/webpack project to vite (preparation before i want to migrate to Vue 3).
Whenever i run vite, the app doesn't load in the browser. Instead i see a Uncaught TypeError: Vue is undefined from vue-i18n, see attached screenshots

Expected behavior

It works like with webpack/vue-cli (v5)

Reproduction

src/main.ts

import { i18n } from '@/i18n';

...
Vue.use(VueI18n);

...
new Vue({
  // eslint-disable-next-line
  // @ts-ignore
  vuetify,
  router,
  i18n,
  pinia,
  async created () {
    // Interceptors Init
    httpClient.interceptors()
  },
  render: (h) => h(App)
}).$mount('#app')

src/i18n/index.tx

import VueI18n from 'vue-i18n';
import { mergeTranslations } from '@/services/i18n';

export const i18n = new VueI18n({
  locale: 'en',
  fallbackLocale: 'en',
  messages: mergeTranslations()
})

System Info

vue: 2.7.10
vue-i18n: 8.28.2


Browsers tested: Firefox, Chrome

Screenshot

vue-i18n error 1
vue-i18n error 2

Additional context

No response

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