Warning from Vue Router: Issue with push/replace state - TypeError: history[(intermediate value)(intermediate value)(intermediate value)] is not a valid function

I've been working on setting up Vue Router (Vue 3 + Vue Router 4) and I'm facing some challenges with the following error messages:

[Vue Router warn]: Error with push/replace State TypeError: history[(intermediate value)(intermediate value)(intermediate value)] is not a function

[Vue Router warn]: Unexpected error when starting the router: TypeError: Cannot read properties of null (reading 'back')

Uncaught TypeError: Cannot read properties of null (reading 'back')

Below is my main.ts file:

import { createApp } from "vue";
import App from "./App.vue";
import store, { storeKey } from "./store/index";

// styling
import "./scss/base.scss";
import router from "./router";

createApp(App).use(router).use(store, storeKey).mount("#app");

And this is my router.ts file content:

import {
  createRouter,
  createWebHashHistory,
  Router,
  RouteRecordRaw,
} from "vue-router";
import Home from "@/components/Home.vue";
import FetchInfo from "@/components/FetchInfo.vue";

const routes: RouteRecordRaw[] = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/requests",
    name: "Requests",
    component: FetchInfo,
  },
];

const router: Router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;

Any suggestions on how to troubleshoot and resolve the above error?

The versions I am using include:

  • "vue": "^3.2.13",
  • "vue-router": "^4.0.15",
  • "webpack": "^5.72.1",
  • "webpack-dev-server": "^4.9.0"

Answer №1

If you happen to find yourself in a situation where you are using Vue Router alongside Office.js, it's worth noting that there is a known bug within the Office.js code that mistakenly sets window.history.replaceState and window.history.pushState to null. This issue can cause Vue Router to malfunction and result in the error described by the original poster. Additionally, in my experience, it led to the page continuously reloading in rapid succession.

For more information on this issue and a related pull request, you can visit this link. The PR is currently pending approval as of December 2022.

Answer №2

This solution successfully resolved the issue:

By initializing a new router with the following code snippet:
router: Router = createRouter({ history: createMemoryHistory(), routes, });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring ways to retrieve checkbox values instead of boolean values upon submission in Angular

I am currently working with a template-driven form and facing an issue. Despite receiving true or false values, I actually need to retrieve the value of checkboxes. <form #f = "ngForm" (ngSubmit) = "onClickSubmit(f.value)"> ...

Implementing user session management with VueJS

I'm currently working on finding a way to preserve user sessions even after they log out. This includes storing multiple shopping carts, transactions, and past searches. As someone who is new to backend languages, I could really use some guidance on t ...

Remove the array stored in the local storage of an Ionic 2 application

In my application, I store data in a string. To convert the data into arrays, I use JSON.parse. this.items = JSON.parse(todos); On the results page, I display my arrays as follows: Array1 Array2 Array3 However, I have noticed that the delete button aft ...

The server failed to start with exit code 1 - Command execution terminated

Upon my initial attempt to launch a server from vite (vue/javascript), I encountered the exit 1 code error. Despite successfully installing the latest versions of vite/vue globally (vue 3.4.21, @vitejs/plugin-vue 5.0.4, vite 5.2.6). I have gone the route ...

Dealing with Axios errors and handling the response object from the err.response

My React/Redux action creator sends a post request when creating a new user account. During server validation testing, I expect the err.response object to be defined in the catch block and return the validation error message. However, I am seeing the gene ...

The Angular 2 router UMD file, router.umd.js, was not found

Trying to run an Angular 2 project and implement @angular/router is proving to be a bit challenging. Everything seems to be working fine, until the moment I attempt: import { provideRouter, RouterConfig } from '@angular/router'; As it tries to ...

Issues with Nuxt 3 middleware causing layout to fail updating post-navigation when using distinct login layout

Encountering a challenge in Nuxt 3 where the layout fails to update properly after navigation in a middleware, particularly when utilizing different layouts for the login page versus other pages. Here's an outline of the configuration: A middleware i ...

Retrieve information from a JSON string

My function is not returning the title of the interval, it keeps returning undefined. Function filterByCategories () { return _.orderBy(this.meetups.filter(item => { console.log('title: ' + JSON.stringify(item.interval.title, n ...

Ways to resolve the issue of incompatible parameters 'action' types in JavaScript

I'm encountering a common problem, but I can't figure out why this error is happening. After updating redux, I encountered the following error message: TS2322: Type '(state: ILanguage | undefined, action: PayloadAction<ILanguage>) =&g ...

The Vuetify table encounters a loading error when trying to retrieve data

Encountering an error with the following code 'Property "item" was accessed during render but is not defined on instance'. However, when I switch it to a normal everything functions properly. <!DOCTYPE html> <html lang="e ...

VueJS not refreshing DOM after AJAX data modification

Utilizing Vue.js to make changes to my DOM, I have implemented the fetch_data() method. This method attempts to update data.messages to display 'Love the Vue.JS' once the AJAX call is successfully completed. The AJAX call executes successfully a ...

How to format decimals in Typescript/Angular with a pipe: comma or dot?

I've recently developed a custom pipe and I'm looking to enhance it by adding commas or periods to thousands values. For instance, 1000 should be displayed as either 1,000 or 1.000. Here is the code snippet for my custom pipe: import { Pipe, Pi ...

viewing vue documentation from your local machine

I was attempting to run the Vue.js documentation offline (locally) and encountered an issue. It had worked previously, but now I'm unsure of what went wrong. I followed the steps outlined in this post: here The basic steps are: Install hexo-cli gl ...

Dealing with TypeScript errors TS2082 and TS2087 when trying to assign an Away3D canvas to a variable

As a beginner with TypeScript, I am in the process of creating an Away3D scene where a canvas element is dynamically generated and needs to be appended to a container. Although the code functions correctly, I am encountering the following compilation erro ...

What's the best way to invoke this specific TypeScript function?

I have come across a library that includes the following function declaration: import { Auth0JwtStrategy } from './strategy/auth0-jwt.strategy'; import { Auth0Service } from './auth0.service'; import { Auth0Options } from './auth0. ...

What are the drawbacks of combining exports through re-exporting in TypeScript?

Lately in TypeScript discussions, there seems to be a negative viewpoint on namespace BAD. However, I see value in organizing related declarations within a single namespace, similar to a library, to avoid excessive import statements. I have come across th ...

What is the correct way to handle the return value of an useAsyncData function in Nuxt 3?

How can I display the retrieved 'data' from a useAsyncData function that fetches information from a pinia store? <script setup lang="ts"> import { useSale } from "~/stores/sale"; const saleStore = useSale(); const { da ...

Issues with VueJS rendering have been observed on MacOS with both Safari and Chrome browsers

Encountering an unusual issue here. My VueJS application, sourced from CDN, incorporates Vuetify. Interestingly, it functions seamlessly on Ubuntu and Windows; however, my client reports observing raw VueJS code when accessing the app via Safari on his iP ...

Struggling with implementing heatmap charts in highcharts-vue

Currently, I am utilizing the official highcharts-vue extension within my vue-3 project. Basic charts such as line and area are functioning properly by using it. However, I am encountering difficulties in getting a heatmap chart to work. The challenge lies ...

The process of building a Vue application encountered an error when attempting to run the command "npm run build"

I recently cloned a Vue application from GitHub (https://github.com/jimmerioles/progressive-weather-app) for setting up automated deployment in Jenkins. Before proceeding, I'm testing it on my Ubuntu machine (GCP VM). I have already installed Java, No ...