Fix "cannot resolve symbol 'routes'" in IntelliJ IDE's
While using WebStorm to code, I ran into an issue with my import statement:
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
What is happening is the Jetbrains IDE is reading the type file for the package from /jetbrains/intellij/javascript/typings instead of the project's node_modules folder.
This happens because the IDE downloads typings for libraries to its configuration folder to enhance code completion.
Luckily, I found threads discussing this issue on stackoverflow, and what was shared worked to resolve the issue.
Here's what to do:
In the IDE, double tap shift two times to open the search everywhere window, search for
registryand open theRegistry...result.In the registry, remove
react-router-domfrom the value field of thetypescript.external.type.defintions.packageskey.Finally, click File => Invalidate Caches, then check
Clear file system cache and Local History, then clickInvalidate and Restart.
This change will ensure the IDE will read the type file from the node_modules folder instead of the internal typings folder. FYI, this registry is "IDE level", not "project level".