'vue error "cannot read property of undefined (reading 'call')" after building project

import Root from './Root.vue';
import NotFound from '../views/NotFound.vue';

const locale = localStorage.getItem('locale');

const routes = [
  {
    path: '',
    redirect: locale,
  },
  {
    path: '/:locale/',
    component: Root,
    children: [
      {
        path: 'company/:company_id',
        name: 'Company',
        component: () => import('../views/dashboard/Dashboard.vue'),
      },
      {
        path: '/',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/Dashboard.vue'),
      },
      {
        path: 'notification',
        name: 'Notification',
        component: () => import('@/views/dashboard/Notification.vue'),
      },
    ],
  },
  {
    path: '*',
    name: 'NotFound',
    component: NotFound,
  },
];

export default routes;

I have an application and there is two mode for building it and here is my vue.config.js file

const path = require('path');

let publicPath;
let outputDir;
switch (process.env.NODE_ENV) {
  case 'development':
    publicPath = '/';
    outputDir = path.resolve(__dirname, 'dist/development/');
  break;
  case 'production':
    publicPath = '/';
    outputDir = path.resolve(__dirname, 'dist/production/');
  break;
  default:
    publicPath = '/';
    outputDir = path.resolve(__dirname, 'dist/development/');
}

module.exports = {
  publicPath,
  outputDir,
};

but sometimes in the development mode or in the production mode after page builds I get this error and the current component will not mount

enter image description here

The problem is when the code runs in the production or development mode the above error occurs and the current component don't render.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source