Vue import causing cannot assign to read only property 'exports' of object error

Viewed 820

I am currently migrating a HTML template to Vue. Now I started to import the Javascript files in the main.js file stored inside src.

My file looks like the following:

import Vue from "vue";
import App from "./App.vue";
import router from "./router";

import pageLoader from "./assets/js/global/page-loader";
import tooltips from "./assets/js/global/tooltips";

Vue.use(pageLoader);
Vue.use(tooltips);

Vue.config.productionTip = false;

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

Every Javascript file is located inside the src/js folder

But once I run the application I receive the following error:

Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
    at Module.eval (webpack-internal:///./src/assets/js/utils/plugins.js:56)
    at eval (webpack-internal:///./src/assets/js/utils/plugins.js:57)
    at Module../src/assets/js/utils/plugins.js (app.js:1579)
    at __webpack_require__ (app.js:849)
    at fn (app.js:151)
    at eval (webpack-internal:///./src/assets/js/global/tooltips.js:1)
    at Object../src/assets/js/global/tooltips.js (app.js:1556)
    at __webpack_require__ (app.js:849)
    at fn (app.js:151)
    at eval (webpack-internal:///./src/main.js:15)

The whole Projects can be seen on github on the following link: Link to github

What is causing this error? I would appreciate any kind of help to fix my issue.

1 Answers

Your files aren't exporting the functions that Vue is trying to use.

What you need to do is export the function you have located in your file.

Please see this guide to exporting functions in VueJs: https://medium.com/js-dojo/a-beginners-guide-to-exports-in-es6-af27b5a621d0

This will help you understand how you need to export functions from these files that Vue will use to run.

Related