I’m developing an addin for Microsoft Word using the OfficeJS API and working in VS Code. For navigation between multiple pages, I wanted to use react-router-dom. However, I’ve run into a problem with version 6 of react-router-dom not supporting “Routes” in my project (more details on this issue can be found here: https://github.com/OfficeDev/office-js/issues/3799).
To work around this, I downgraded to version 5.3.4 of react-router-dom, intending to use “Switch” for routing. Despite this, I am encountering an error that states:
Message error in index.tsx:
Package.json:
I have double-checked, and Switch is indeed be available in react-router-dom v5.3.4.
It seems like VS Code is not acknowledging the downgrade to version 5.3.4 because I don’t get this error when I import “Routes” (which was only introduced in v6).
I suspect there might be some caching issue, but I haven’t been able to locate and resolve it.
Here are the steps I’ve tried so far:
Reinstalling react-router-dom:
-
I used npm uninstall react-router-dom followed by npm install [email protected].
-
Clearing the npm cache: I ran npm cache clean –force.
-
VS Code: Closed and reopened VS Code multiple times.
Despite these efforts, the issue persists.
Does anyone have any ideas on how to resolve this problem? Any help would be greatly appreciated!
Thank you.