remix-run / react-router

Declarative routing for React
https://reactrouter.com
MIT License
53.25k stars 10.32k forks source link

[Bug]: ESLint - Unable to resolve path to module 'react-router/dom'. #12371

Closed Arkellys closed 2 days ago

Arkellys commented 2 days ago

What version of React Router are you using?

7.0.1

Steps to Reproduce

I've followed upgrading from v6 documentation:

yarn remove react-router-dom
yarn add react-router@latest

And:

- import { RouterProvider } from "react-router-dom";
+ import { RouterProvider } from "react-router/dom";

This is my jsconfig.json config:

"compilerOptions": {
  "target": "es2022",
  "checkJs": false,
  "baseUrl": "./",
  "resolveJsonModule": true,
  "moduleResolution": "bundler",
  "jsx": "react-jsx"
}

And I'm using eslint-plugin-import v2.31.0 along with ESLint v9.15.0. The relevant rule configuration is:

{
  rules: {
    "import/no-unresolved": ["error", { commonjs: true }]
  }
}

Expected Behavior

I expect ESLint no to flag "react-router/dom" import as unresolved.

Actual Behavior

I get a ESLint import/unresolved error on the import "react-router/dom". The imports from "react-router" are not flagged. This is just a ESLint error, the import works fine and my IDE resolves it correctly. Restarting the IDE and ESLint Server didn't solve the issue.

Honestly, I can't tell if the bad configuration comes from my project, react-router or eslint-plugin-import?

timdorr commented 2 days ago

My best guess is you have a cache somewhere that's out of date. Try deleting your node_modules folder, as it's often stored there.

Unfortunately, this isn't an issue with the library.

teague-mfa commented 22 hours ago

I have the same problem after running rm -rf node_modules and npm cache clean --force.