Vue.config.silent is undefined when using with Vue 2.7
See original GitHub issueReporting 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
- Read the Contributing Guidelines
- Read the Documentation
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, vue-i18n-composable docs is bad… I’ve just merged PR!
Thanks!
Thank you for your repo!
I’ve just checked your repo! I noticed that vue-i18n isn’t installed by
Vue.use
.