question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue.config.silent is undefined when using with Vue 2.7

See original GitHub issue

Reporting a bug?

I am trying to use vue-i18n with vue 2.7 (and vue-i18n-composable, but I think the issue lies within vue-i18n). When I serve my site with npm run serve (using the vue-cli) and try to open it in a browser I get the error that Vue.config.silent is undefined.

app.js:5181 Uncaught TypeError: Cannot read properties of undefined (reading 'config')
    at VueI18n._initVM (vue-i18n.esm.js?a4e8:1353:1)
    at new VueI18n (vue-i18n.esm.js?a4e8:1292:1)
    at createI18n (index.mjs?0914:6:1)
    at eval (main.ts?5e60:18:1)
    at ./src/main.ts (app.js:2621:1)
    at __webpack_require__ (app.js:5178:33)
    at app.js:6295:109
    at __webpack_require__.O (app.js:5227:23)
    at app.js:6296:53
    at app.js:6298:12

I think this is caused by Vue 2.7 not setting window.Vue anymore in ESM builds: https://github.com/vuejs/vue/blob/main/CHANGELOG.md#notes-on-api-exposure

Expected behavior

Should not throw an error.

Reproduction

import Vue from "vue";
import {createI18n} from "vue-i18n-composable";
import App from "./App.vue";

const i18n = createI18n();

new Vue({
  i18n,
  render: h => h(App),
}).$mount("#app");

System Info

@intlify/vue-i18n-loader: ^4.0.0 => 4.0.0
    @vue/cli-plugin-eslint: ^5.0.7 => 5.0.7
    @vue/cli-plugin-typescript: ^5.0.6 => 5.0.7
    @vue/cli-plugin-unit-jest: ^5.0.6 => 5.0.7
    @vue/cli-service: ^5.0.7 => 5.0.7
    @vue/composition-api: ^1.6.3 => 1.6.3
    @vue/test-utils: ^1.3.0 => 1.3.0
    @vue/vue2-jest: ^27.0.0 => 27.0.0
    vue: ^2.7.2 => 2.7.2
    vue-cli-plugin-i18n: ^2.3.1 => 2.3.1
    vue-cli-plugin-vuetify: ^2.5.1 => 2.5.1
    vue-i18n: ^8.27.2 => 8.27.2
    vue-i18n-composable: ^2.0.0 => 2.0.0
    vuetify: ^2.6.7 => 2.6.7
    vuetify-loader: ^1.7.3 => 1.7.3

Screenshot

No response

Additional context

Workaround: Add Vue instance to the window object manually:

import Vue from "vue";

window.Vue = Vue;

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
kazuponcommented, Jul 15, 2022

Sorry, vue-i18n-composable docs is bad… I’ve just merged PR!

Thanks!

1reaction
kazuponcommented, Jul 15, 2022

Thank you for your repo!

I’ve just checked your repo! I noticed that vue-i18n isn’t installed by Vue.use.

 import Vue from 'vue'
+import VueI18n from 'vue-i18n'
 import { createI18n } from 'vue-i18n-composable'
 import App from './App.vue'

 Vue.config.productionTip = false

+Vue.use(VueI18n)
 const i18n = createI18n()

 new Vue({
   i18n,
   render: h => h(App),
 }).$mount('#app')
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my vue.config.js file not working? - Stack Overflow
In the Vue-CLI v. 4.5. 13 (with @vue/cli-service@4.3.1 ), there is a bug documented here that causes a silent failure if there is...
Read more >
API - Vue.js
Global Config. Vue.config is an object containing Vue's global configurations. You can modify its properties listed below before bootstrapping your application: ...
Read more >
import vue from 'vue' window.vue = vue; error - You.com
When I serve my site with npm run serve (using the vue-cli) and try to open it in a browser I get the...
Read more >
fork-ts-checker-webpack-plugin - npm
Start using fork-ts-checker-webpack-plugin in your project by running `npm i ... To enable Vue.js support, follow these steps: Expand Vue.js ...
Read more >
How to Migrate from Vue CLI to Vite - Vue School Blog
js file looks like when generating a brand new Vite project for Vue using npm init vite@latest . // vite.config.js import { defineConfig...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found