Skip to content
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

Cannot find module '@reduxjs/toolkit/query/react'. when "moduleResolution": "node16". #50857

Closed
uk-taniyama opened this issue Sep 20, 2022 · 3 comments
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@uk-taniyama
Copy link

Bug Report

'@reduxjs/toolkit/query/react' has nested package.json.
BUT some other package use package.json exports.

🔎 Search Terms

moduleResolution, node16

🕗 Version & Regression Information

Version 4.8.3

💻 Code

import {createApi} from '@reduxjs/toolkit/query/react';

🙁 Actual behavior

"moduleResolution": "Node16" traceResolution

$ tsc --noEmit --traceResolution
File '/tmp/work/src/package.json' does not exist.
Found 'package.json' at '/tmp/work/package.json'.
'package.json' does not have a 'typesVersions' field.
======== Resolving module '@reduxjs/toolkit/query/react' from '/tmp/work/src/index.ts'. ========
Explicitly specified module resolution kind: 'Node16'.
File '/tmp/work/src/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/package.json' exists according to earlier cached lookups.
Loading module '@reduxjs/toolkit/query/react' from 'node_modules' folder, target file type 'TypeScript'.
Directory '/tmp/work/src/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'reduxjs__toolkit/query/react'
Found 'package.json' at '/tmp/work/node_modules/@reduxjs/toolkit/query/react/package.json'.
'package.json' does not have a 'typesVersions' field.
Found 'package.json' at '/tmp/work/node_modules/@reduxjs/toolkit/package.json'.
'package.json' does not have a 'typesVersions' field.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react.ts' does not exist.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react.tsx' does not exist.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'dist/index.d.ts' that references '/tmp/work/node_modules/@reduxjs/toolkit/query/react/dist/index.d.ts'.
Loading module as file / folder, candidate module location '/tmp/work/node_modules/@reduxjs/toolkit/query/react/dist/index.d.ts', target file type 'TypeScript'.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react/index.ts' does not exist.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react/index.tsx' does not exist.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react/index.d.ts' does not exist.
Directory '/tmp/work/node_modules/@types' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'reduxjs__toolkit/query/react'
Directory '/tmp/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'reduxjs__toolkit/query/react'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'reduxjs__toolkit/query/react'
File '/tmp/work/src/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/package.json' exists according to earlier cached lookups.
Loading module '@reduxjs/toolkit/query/react' from 'node_modules' folder, target file type 'JavaScript'.
Directory '/tmp/work/src/node_modules' does not exist, skipping all lookups in it.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/@reduxjs/toolkit/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react.js' does not exist.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react.jsx' does not exist.
'package.json' has 'main' field 'dist/index.js' that references '/tmp/work/node_modules/@reduxjs/toolkit/query/react/dist/index.js'.
Loading module as file / folder, candidate module location '/tmp/work/node_modules/@reduxjs/toolkit/query/react/dist/index.js', target file type 'JavaScript'.
File name '/tmp/work/node_modules/@reduxjs/toolkit/query/react/dist/index.js' has a '.js' extension - stripping it.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react/index.js' does not exist.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react/index.jsx' does not exist.
Directory '/tmp/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@reduxjs/toolkit/query/react' was not resolved. ========
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist.
Found 'package.json' at '/tmp/work/node_modules/typescript/package.json'.
'package.json' does not have a 'typesVersions' field.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/tmp/work/node_modules/typescript/package.json' exists according to earlier cached lookups.
src/index.ts(1,25): error TS2307: Cannot find module '@reduxjs/toolkit/query/react' or its corresponding type declarations.

🙂 Expected behavior

"moduleResolution": "Node" traceResolution

$ tsc --noEmit --traceResolution
======== Resolving module '@reduxjs/toolkit/query/react' from '/tmp/work/src/index.ts'. ========
Explicitly specified module resolution kind: 'NodeJs'.
Loading module '@reduxjs/toolkit/query/react' from 'node_modules' folder, target file type 'TypeScript'.
Directory '/tmp/work/src/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'reduxjs__toolkit/query/react'
Found 'package.json' at '/tmp/work/node_modules/@reduxjs/toolkit/query/react/package.json'.
'package.json' does not have a 'typesVersions' field.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react.ts' does not exist.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react.tsx' does not exist.
File '/tmp/work/node_modules/@reduxjs/toolkit/query/react.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field '../../dist/query/react/index.d.ts' that references '/tmp/work/node_modules/@reduxjs/toolkit/dist/query/react/index.d.ts'.
File '/tmp/work/node_modules/@reduxjs/toolkit/dist/query/react/index.d.ts' exist - use it as a name resolution result.
Resolving real path for '/tmp/work/node_modules/@reduxjs/toolkit/dist/query/react/index.d.ts', result '/tmp/work/node_modules/@reduxjs/toolkit/dist/query/react/index.d.ts'.
======== Module name '@reduxjs/toolkit/query/react' was successfully resolved to '/tmp/work/node_modules/@reduxjs/toolkit/dist/query/react/index.d.ts' with Package ID '@reduxjs/toolkit-query-react/eact/index.d.ts@1.0.0'. ========
@IllusionMH
Copy link
Contributor

Most likely it should be addressed in RTK package
reduxjs/redux-toolkit#2485

@uk-taniyama
Copy link
Author

ok. but....
i dont understand next point.

  • Why and what is the purpose of searching package.json?
  • Why use the unexpected package.json in post-processing?

this package.json is expected.

Found 'package.json' at '/tmp/work/node_modules/@reduxjs/toolkit/query/react/package.json'.
'package.json' does not have a 'typesVersions' field.

this package.json is not expected.

Found 'package.json' at '/tmp/work/node_modules/@reduxjs/toolkit/package.json'.
'package.json' does not have a 'typesVersions' field.

and next pakcage.json is not expected.
maybe '/tmp/work/node_modules/@reduxjs/toolkit/package.json'.

'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'dist/index.d.ts' that references '/tmp/work/node_modules/@reduxjs/toolkit/query/react/dist/index.d.ts'.

@RyanCavanaugh RyanCavanaugh added the External Relates to another program, environment, or user action which we cannot control. label Sep 21, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked as 'External' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

4 participants