Vue-cli:Module not found: Error: Can‘t resolve ‘vue-router ‘

created at 06-19-2022 views: 151


Compiled with problems:X

ERROR in ./src/router/index.js 2:0-23

Module not found: Error: Can't resolve 'vue ' in 'D:\F\XX\project-SPH\app\src\router'

ERROR in ./src/router/index.js 3:0-36

Module not found: Error: Can't resolve 'vue-router ' in 'D:\F\XX\project-SPH\app\src\router'

ERROR in ./src/router/index.js 8:0-36
Module not found: Error: [CaseSensitivePathsPlugin] `D:\F\XX\project-SPH\app\src\pages\search\index.vue` does not match the corresponding path on disk `Search`.

The wrong index.js code at this time is as follows:

// where to configure the route
import Vue from 'vue';
import VueRouter from 'vue-router ';//Use plugin
//Introduce routing components
import Home from '@/pages/Home'
import Search from '@/pages/search'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
//configure routing
export default new VueRouter({
//configure routing
         path : "/home",
         path: " /search",
         path: " /login",
         path: "/register",


At first, it was because Vue-router could not be installed. It is suspected that the Vue-router library is not installed and reported

After an afternoon of google, I couldn't find the reason, and finally decided to look at the meaning of the code error by myself. There are a total of 3 codes: all point to the index.js file.

The first place: pointing to Search, I looked at the place where Search was quoted, and found that it was written in lowercase.

import Search from '@/page/search' // here, should be '@/page/Search'

The second place: The place where vue and vue-router are imported. After careful observation, I found that I wrote an extra space.

import Vue from 'vue ' // note the blank
import VueRouter from 'vue-router ' // note the blank


created at:06-19-2022
edited at: 06-19-2022: