Skip to content

Import path '@reduxjs/toolkit/query' cannot be resolved if moduleResolution is set to Node16 or NodeNext. #2894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yukiyokotani opened this issue Nov 10, 2022 · 1 comment

Comments

@yukiyokotani
Copy link

The import from '@reduxjs/toolkit/query' in the sample below cannot be resolved if the moduleResolution in tsconfig is set to Node16 or NodeNext.

https://redux-toolkit.js.org/rtk-query/usage/manual-cache-updates#optimistic-updates

Error message is

Cannot find module '@reduxjs/toolkit/query' or its corresponding type declarations.ts(2307)

I think the following exports should be set in package.json.

"exports": {
  ".": {
    "types": "./dist/index.d.ts",
    "import": "./dist/redux-toolkit.esm.js",
    "require": "./dist/index.js"
  },
  "./query": {
    "types": "./dist/query/index.d.ts",
    "import": "./dist/query/rtk-query.esm.js",
    "require": "./dist/query/index.js"
  }
},

As a side note, at this time it is possible to import from '@reduxjs/toolkit/dist/query' instead, even for Node16 or NodeNext.

@yukiyokotani
Copy link
Author

Sorry, this issue was a duplicate of #2485. Withdrawal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant