How to fix window is not defined in Vue.js?

Sometimes, we want to fix window is not defined in Vue.js.

In this article, we’ll look at how to fix window is not defined in Vue.js.

How to fix window is not defined in Vue.js?

To fix window is not defined in Vue.js, we should add the browser property and set it to true in the ESLint config.

For instance, we write

module.exports = {
  //...
  env: {
    browser: true,
    node: true,
  },
  //...
};

to add the env.browser property and set it to true so ESLint will stop throwing the window is not defined error.

Conclusion

To fix window is not defined in Vue.js, we should add the browser property and set it to true in the ESLint config.