Error Module not found: Error: Can't resolve 'vue-router' reported in Vue-cli

Vue-cli中报错 Module not found: Error: Can’t resolve ‘vue-router’ in ‘D:\GithubProject\shoppingsystem\shopping-system\src\router’

Background
When configuring the Shangpinhui environment in Silicon Valley, the following error is reported:
insert image description here
error code

//配置路由的地方
import Vue from 'vue';
import VueRouter from 'vue-router';
//使用插件
Vue.use(VueRouter);
//引入路由组件
import Home from '@/pages/Home'
import Search from '@/pages/Search'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
//配置路由
export default new VueRouter({
    
    
    routes:[
        {
    
    
            path:'/home',
            component:Home
        },
        {
    
    
            path:'/search',
            component:Search
        },
        {
    
    
            path:'/login',
            component:Login
        },
        {
    
    
            path:'/register',
            component:Register
        }
    ]
})

After looking at my code, there is no problem, and then I opened the bilibili video comment. It seems that other big guys have solutions.
Use npm install --save vue-router@3 to install version 3.5.5, and the result can run
the problem that has troubled me for hours Finally solved, thanks to this big guy
insert image description here

Summarize

If you encounter problems, you can take a look at the video comments, there are big guys in the comments

Guess you like

Origin blog.csdn.net/TotoroChinchilla/article/details/129030398