[Front-end problem record] front-end error: Error: Cannot find module '@/views/index'

Preliminary summary: Everything is normal when I develop locally, but I deploy it to the test environment. The login page will appear, but an error is reported after entering the user name and password, and the following error is reported: the back-end interface is called successfully, and the token is returned, but the page keeps loading (the home page cannot be loaded)

Error: Cannot find module ‘@/views/index’

 I found several blogs to try to solve this problem:

Vue routing jump error: Error: Redirected when going from “/login” to “/home” via a navigation guard._weixin_44039043's Blog-CSDN Blog

Solve the problem of Redirected when going from "/xxx" to "/yyy" via a navigation guard. Error in VUE routing jump - the short book  mentioned that there is a problem with the routing router of vue

One of the methods is to add the following code to index.js under the router folder:

const originalPush = Router.prototype.push;
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch((err) => err);
};

So I tried

Another solution is to modify the version of vue-router.

 I tried it and reinstalled once, then packaged and deployed again as required.

npm install

 

The problem is solved! After logging in, you can enter the index home page, but the console reports an error. Every time the menu is clicked, an error will be reported:

TypeError: Cannot read property 'catch' of undefined

TypeError: Cannot read property 'meta' of null

 

I searched for the problem again on Baidu and referred to the blog

Cannot read property 'catch' of undefined_Xiaobai is still on the road blog-CSDN blog

 I try to delete the js code just added in the index under the router folder, and package and deploy again.

Guess you like

Origin blog.csdn.net/Sabrina_cc/article/details/123091543