Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm creating a Vue3 application and after I added the router, my first page is loading but it's completely blank.
I'm receiving the following
Errors: Uncaught TypeError: Object(...) is not a function
In console:
Warning in ./src/router/index.js "export 'createRouter' was not found
in 'vue-router'
Warning in ./src/router/index.js "export 'createWebHistory' was not
found in 'vue-router'
router -> index.js
import { createWebHistory, createRouter } from "vue-router";
const routes = [{
path: "/user/create",
name: "createUser",
component: createUser,
path: "/users",
name: "listUser",
component: listUser,
meta: { requiresAuth: true }
path: "/user/show/:id",
name: "showUser",
component: showUser,
meta: { requiresAuth: true }
path: "/user/update/:id",
name: "updateUser",
component: updateUser,
path: "/login",
name: "login",
component: Login
path: "/register",
name: "register",
component: Register
path: "/users/bearer",
name: "bearer",
component: bearer,
meta: { requiresAuth: true }
const router = createRouter({
history: createWebHistory(),
routes,
router.beforeEach((to, from, next) => {
const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
const isAuthenticated = firebase.auth().currentUser;
console.log("isauthenticated", isAuthenticated);
if (requiresAuth && !isAuthenticated) {
next("/login");
} else {
next();
export default router;
Found the answer to this here:
Stackoverflow question
You need to install the router via npm
npm install vue-router@next --save
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.