Vite / Vue / HMR : ReferenceError: Cannot access '...' before initialization

1.2k views Asked by At

I splitted some pieces of my code into separate files for better readability. Since, the Vite HMR is not working anymore. I get errors like the one below in the console :

ReferenceError: Cannot access 'axios' before initialization

I have this file structure :

app.js

import Vue from 'vue';
import './plugins/vue-axios';

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

plugins/vue-axios.js:

import Vue from 'vue';
import VueAxios from 'vue-axios';
import axios from '../helpers/axios';

Vue.use(VueAxios, axios);

It works fine at the first build (dev or production). But the errors occurs when HMR tries to reload a component.

0

There are 0 answers