I’m trying to start a new project using vue js. I think I have all the dependencies I need through the terminal. I installed npm, vue, vue-bootstrap and vue-router. Error is from line 7 on router.js, Vue.use(VueRouter).
Here’s the code for my main.js
JavaScript
x
16
16
1
import Vue from "vue"
2
import App from "./App.vue"
3
import router from "./router.js"
4
import BootstrapVue from "bootstrap-vue"
5
import "bootstrap/dist/css/bootstrap.css"
6
import "bootstrap-vue/dist/bootstrap-vue.css"
7
8
Vue.use(BootstrapVue)
9
10
Vue.config.productionTip = false
11
12
new Vue({
13
router,
14
render: h => h(App),
15
}).$mount('#app')
16
Here’s my router.js
JavaScript
1
31
31
1
import Vue from "vue"
2
import VueRouter from "vue-router"
3
import Home from "@/pages/Home.vue"
4
import About from "@/pages/About.vue"
5
import Contact from "@/pages/Contact.vue"
6
7
Vue.use(VueRouter)
8
9
export default new VueRouter({
10
mode: 'history',
11
base: process.env.BASE_URL,
12
routes: [
13
{
14
path: '/',
15
name: 'home',
16
component: Home
17
},
18
{
19
path: '/about',
20
name: 'about',
21
component: About
22
},
23
{
24
path: '/contact',
25
name: 'contact',
26
component: Contact
27
}
28
29
]
30
})
31
Sorry, I had the import vue line on the same line as the code indicators and it got cut off, I have the error still.
The full error is this:
JavaScript
1
25
25
1
router.js?41cb:7 Uncaught TypeError: Cannot read properties of undefined (reading 'use')
2
at eval (router.js?41cb:7)
3
at Module../src/router.js (app.js:1261)
4
at __webpack_require__ (app.js:849)
5
at fn (app.js:151)
6
at eval (main.js:12)
7
at Module../src/main.js (app.js:1141)
8
at __webpack_require__ (app.js:849)
9
at fn (app.js:151)
10
at Object.1 (app.js:1274)
11
at __webpack_require__ (app.js:849)
12
eval @ router.js?41cb:7
13
./src/router.js @ app.js:1261
14
__webpack_require__ @ app.js:849
15
fn @ app.js:151
16
eval @ main.js:12
17
./src/main.js @ app.js:1141
18
__webpack_require__ @ app.js:849
19
fn @ app.js:151
20
1 @ app.js:1274
21
__webpack_require__ @ app.js:849
22
checkDeferredModules @ app.js:46
23
(anonymous) @ app.js:925
24
(anonymous) @ app.js:928
25
Advertisement
Answer
Answer from Hiws:
BootstrapVue doesn’t support Vue 3, so you’ll have to either use Vue 2 or use another component library
Thanks.