Vuejs - Uncaught TypeError: Cannot redefine property: $router

Solved!

In my index.html file, I had imported vue again:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>Meko Deng</title>
  </head>
  <body>
    <div id="app"></div>
    <!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script> -->
</body>
</html>

Commenting that out did the trick!


This is due to the following code in vue-router

if (inBrowser && window.Vue) {
  window.Vue.use(VueRouter);
}

which is really only present for when you're including files in <script> blocks (ie, no build system).

Remove any <script> elements relating to Vue or related components; you don't need them when using Webpack.